diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-08-05 01:01:32 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-08-05 01:01:32 -0700 |
commit | fb9dad23be85763ff70e256bc76617e14f13c950 (patch) | |
tree | 154a4eb15aec61c644d78256f0cb07bedc5028af | |
parent | e6e09b16aa646289f0440e136ded1e84f5290a80 (diff) | |
parent | 816c291006296835f51806462b35136740f3e013 (diff) | |
download | scala-fb9dad23be85763ff70e256bc76617e14f13c950.tar.gz scala-fb9dad23be85763ff70e256bc76617e14f13c950.tar.bz2 scala-fb9dad23be85763ff70e256bc76617e14f13c950.zip |
Merge pull request #1051 from lrytz/t6074
SI-6074 disallow implicit enrichment with constructor
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 4 | ||||
-rw-r--r-- | test/files/neg/t6074.check | 4 | ||||
-rw-r--r-- | test/files/neg/t6074.scala | 6 |
3 files changed, 13 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 5403669050..d785988738 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -4522,7 +4522,9 @@ trait Typers extends Modes with Adaptations with Tags { }) setType qual.tpe setPos qual.pos, name) case _ if accessibleError.isDefined => - val qual1 = adaptToMemberWithArgs(tree, qual, name, mode, false, false) + // don't adapt constructor, SI-6074 + val qual1 = if (name == nme.CONSTRUCTOR) qual + else adaptToMemberWithArgs(tree, qual, name, mode, false, false) if (!qual1.isErrorTyped && (qual1 ne qual)) typed(Select(qual1, name) setPos tree.pos, mode, pt) else diff --git a/test/files/neg/t6074.check b/test/files/neg/t6074.check new file mode 100644 index 0000000000..38670e5b3d --- /dev/null +++ b/test/files/neg/t6074.check @@ -0,0 +1,4 @@ +t6074.scala:5: error: constructor A in class A cannot be accessed in object T + def t = new A() + ^ +one error found diff --git a/test/files/neg/t6074.scala b/test/files/neg/t6074.scala new file mode 100644 index 0000000000..8c14f00f19 --- /dev/null +++ b/test/files/neg/t6074.scala @@ -0,0 +1,6 @@ +class A private () { } +class B { } +object T { + implicit def a2b(a: A): B = null + def t = new A() +} |