alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (t3619.scala)

This example Scala source code file (t3619.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

app, app, dep, dep, int, meh, meh, string, string, test

The Scala t3619.scala source code

class Dep(x: Int)(implicit val nameClash: String)

object Test extends App {
  implicit val nameClash: String = "meh"

  def meth(implicit w: String) = 1

  // when typing Meh's default constructor Meh.this.nameClash (inherited from Dep)
  // shadows Test.nameClash, thus, when inferring the argument `w` in the call to meth,
  // Test.nameClash is not eligible statically, Meh.this.nameClash is picked (which then causes the VerifyError)
  // BUG: Meth.this.nameClash should not be in (the implicit) scope during the super constructor call in the first place
  class Meh extends Dep(meth)
  /*
    class Meh extends Dep {
      def this() {
        this(Test.this.meth(Meh.this.nameClash))(Test.this.nameClash)
      }
    }
  */
  
  new Meh
}


/*
  {
    def this(a: String, b: Int) {
      this()
    }
    def this(x: String) {
      this(Meh.this.nameClash, 1)
    }
  }
*/

Other Scala examples (source code examples)

Here is a short list of links related to this Scala t3619.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.