Skip to content

Commit 66adab2

Browse files
committed
Address review comments
1 parent f42822e commit 66adab2

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed

compiler/src/dotty/tools/dotc/core/StdNames.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ object StdNames {
371371
val Import: N = "Import"
372372
val Literal: N = "Literal"
373373
val LiteralAnnotArg: N = "LiteralAnnotArg"
374+
val Matchable: N = "Matchable"
374375
val MatchCase: N = "MatchCase"
375376
val MirroredElemTypes: N = "MirroredElemTypes"
376377
val MirroredElemLabels: N = "MirroredElemLabels"
@@ -387,7 +388,6 @@ object StdNames {
387388
val Ref: N = "Ref"
388389
val RootPackage: N = "RootPackage"
389390
val RootClass: N = "RootClass"
390-
val Matchable: N = "Matchable"
391391
val Select: N = "Select"
392392
val Shape: N = "Shape"
393393
val StringContext: N = "StringContext"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,4 @@ class ReTyper extends Typer with ReChecking {
141141
override protected def addAccessorDefs(cls: Symbol, body: List[Tree])(using Context): List[Tree] = body
142142
override protected def checkEqualityEvidence(tree: tpd.Tree, pt: Type)(using Context): Unit = ()
143143
override protected def matchingApply(methType: MethodOrPoly, pt: FunProto)(using Context): Boolean = true
144-
}
144+
}

library/src/scala/quoted/Quotes.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3375,6 +3375,9 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
33753375
/** The class symbol of core class `scala.Any`. */
33763376
def AnyClass: Symbol
33773377

3378+
/** The class symbol of core trait `scala.Matchable` */
3379+
def MatchableClass: Symbol
3380+
33783381
/** The class symbol of core class `scala.AnyVal`. */
33793382
def AnyValClass: Symbol
33803383

tests/neg/extend-matchable.scala

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
trait M0 extends Matchable // inferred base type is AnyRef
2+
trait M extends Any, Matchable
3+
4+
class C extends Matchable // OK inferred base type is AnyRef
5+
class D(x: Int) extends AnyVal, Matchable // OK
6+
class E extends AnyRef, Matchable // OK
7+
class F extends Any, Matchable // error: Any does not have a constructor
8+
9+
class C1 extends M // OK inferred base type is AnyRef
10+
class D1(x: Int) extends AnyVal, M // OK
11+
class E1 extends AnyRef, M // OK
12+
class F1 extends Any, M // error: Any does not have a constructor
13+
14+
class C2 extends M0 // OK inferred base type is AnyRef
15+
class D2(x: Int) extends AnyVal, M0 // error: illegal trait inheritance
16+
class E2 extends AnyRef, M0 // OK
17+
class F2 extends Any, M0 // error: Any does not have a constructor // error: illegal trait inheritance
18+
19+
20+
21+
22+
23+

tests/pos/i1044.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
object Test {
22
def f[X](x: X) =
3+
???.getClass.getMethods.head.getParameterTypes.mkString(",")
4+
// this is the current behavior. But it would also be OK if `???.getClass` fails
35
x.getClass.getMethods.head.getParameterTypes.mkString(",")
46
}

0 commit comments

Comments
 (0)