Skip to content

Commit 6cda8a6

Browse files
committed
Fix for SI-6263, futile adaptation.
Don't try to implicitly convert an unstable prefix to a stable one by applying a view. As the matrix spoon kid says, "that's impossible."
1 parent d9c0cb6 commit 6cda8a6

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/compiler/scala/tools/nsc/typechecker/Typers.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,11 @@ trait Typers extends Modes with Adaptations with Tags {
233233
* @param tree ...
234234
* @return ...
235235
*/
236-
def checkStable(tree: Tree): Tree =
236+
def checkStable(tree: Tree): Tree = (
237237
if (treeInfo.isExprSafeToInline(tree)) tree
238238
else if (tree.isErrorTyped) tree
239239
else UnstableTreeError(tree)
240+
)
240241

241242
/** Would tree be a stable (i.e. a pure expression) if the type
242243
* of its symbol was not volatile?
@@ -5201,7 +5202,10 @@ trait Typers extends Modes with Adaptations with Tags {
52015202

52025203
def typedSingletonTypeTree(tree: SingletonTypeTree) = {
52035204
val ref1 = checkStable(
5204-
typed(tree.ref, EXPRmode | QUALmode | (mode & TYPEPATmode), AnyRefClass.tpe))
5205+
context.withImplicitsDisabled(
5206+
typed(tree.ref, EXPRmode | QUALmode | (mode & TYPEPATmode), AnyRefClass.tpe)
5207+
)
5208+
)
52055209
tree setType ref1.tpe.resultType
52065210
}
52075211

test/files/neg/t6263.check

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
t6263.scala:5: error: type mismatch;
2+
found : A.this.c.type (with underlying type C)
3+
required: AnyRef
4+
type t = c.type
5+
^
6+
one error found

test/files/neg/t6263.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class C(val a: Any) extends AnyVal
2+
class A {
3+
implicit def c2AnyRef(c: C): AnyRef = new {}
4+
val c = new C(0)
5+
type t = c.type
6+
}

0 commit comments

Comments
 (0)