Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active February 3, 2026 20:22
Show Gist options
  • Select an option

  • Save dacr/341aa1dcb9c2c7a029ee0f8fdb284be1 to your computer and use it in GitHub Desktop.

Select an option

Save dacr/341aa1dcb9c2c7a029ee0f8fdb284be1 to your computer and use it in GitHub Desktop.
scala3 feature examples - transparent traits / published by https://github.com/dacr/code-examples-manager #ada644bc-de96-45f2-8d41-23d58d5708d4/2780feffc899bf9340aea6ae085f89ac73e1205d
// summary : scala3 feature examples - transparent traits
// keywords : scala3, tutorial, @testable
// publish : gist
// authors : David Crosson
// license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
// id : ada644bc-de96-45f2-8d41-23d58d5708d4
// created-on : 2021-12-25T18:51:10+01:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : scala-cli $file
//> using scala "3.4.2"
// -----------------------------------------------------
transparent trait TechnicalTrait:
def machin() = "machin"
trait DomainTrait:
def truc() = "truc"
// -----------------------------------------------------
@main def go():Unit =
val that = new DomainTrait() with TechnicalTrait
println("The TechnicalTrait is hidden to the type inference engine !")
println("=> DomainTrait INSTEAD OF DomainTrait & TechnicalTrait")
println("Better readability in IDE, REPL, Exceptions, ...")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment