Skip to content

Commit 3487139

Browse files
committed
Fix #3537: Don't add an implicit to qualifier of constructor
When trying to insert an implicit on the qualifier of a method call, make sure the call is not to a constructor, as this would lead to illegal bytecode.
1 parent be50d2c commit 3487139

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1912,7 +1912,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
19121912
*/
19131913
def tryInsertImplicitOnQualifier(tree: Tree, pt: Type)(implicit ctx: Context): Option[Tree] = trace(i"try insert impl on qualifier $tree $pt") {
19141914
tree match {
1915-
case Select(qual, name) =>
1915+
case Select(qual, name) if name != nme.CONSTRUCTOR =>
19161916
val qualProto = SelectionProto(name, pt, NoViewsAllowed, privateOK = false)
19171917
tryEither { implicit ctx =>
19181918
val qual1 = adaptInterpolated(qual, qualProto)

tests/neg/i3537.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import dotty.Show._
2+
3+
class Foo(x: Int)
4+
5+
object Test {
6+
val res0 = new Foo("Hello") // error
7+
}

0 commit comments

Comments
 (0)