File tree Expand file tree Collapse file tree 4 files changed +23
-4
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 4 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -595,8 +595,11 @@ object SymDenotations {
595
595
)
596
596
597
597
/** Is this a denotation of a stable term (or an arbitrary type)? */
598
- final def isStable (implicit ctx : Context ) =
599
- isType || is(Stable ) || ! (is(UnstableValue ) || info.isInstanceOf [ExprType ])
598
+ final def isStable (implicit ctx : Context ) = {
599
+ def isUnstable =
600
+ is(UnstableValue ) || info.isInstanceOf [ExprType ] && ! info.isStable
601
+ isType || is(Stable ) || ! isUnstable
602
+ }
600
603
601
604
/** Is this a "real" method? A real method is a method which is:
602
605
* - not an accessor
Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ object Types {
115
115
case tp : RefinedOrRecType => tp.parent.isStable
116
116
case tp : ExprType => tp.resultType.isStable
117
117
case tp : AnnotatedType => tp.tpe.isStable
118
- case _ => false
118
+ case tp => tp.derivesFrom(defn. SingletonClass )
119
119
}
120
120
121
121
/** Is this type a (possibly refined or applied or aliased) type reference
Original file line number Diff line number Diff line change @@ -417,7 +417,7 @@ object ProtoTypes {
417
417
418
418
/** Create a new TypeVar that represents a dependent method parameter singleton */
419
419
def newDepTypeVar (tp : Type )(implicit ctx : Context ): TypeVar =
420
- newTypeVar(TypeBounds .upper(AndType (tp, defn.SingletonClass .typeRef)))
420
+ newTypeVar(TypeBounds .upper(AndType (tp.widenExpr , defn.SingletonClass .typeRef)))
421
421
422
422
/** The result type of `mt`, where all references to parameters of `mt` are
423
423
* replaced by either wildcards (if typevarsMissContext) or TypeParamRefs.
Original file line number Diff line number Diff line change
1
+ trait Foo {
2
+ type Out
3
+ def out : Out
4
+ }
5
+
6
+ object Test extends App {
7
+
8
+ implicit def bar (implicit foo : => Foo & Singleton ): foo.Out = foo.out
9
+
10
+ var x = new Foo { type Out = String ; def out = " hello" }
11
+
12
+ implicit val y : Foo = x
13
+
14
+ assert(bar(y) == " hello" )
15
+ assert(bar == " hello" )
16
+ }
You can’t perform that action at this time.
0 commit comments