diff options
author | Adriaan Moors <adriaan@lightbend.com> | 2016-10-11 12:57:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-11 12:57:58 -0700 |
commit | 95b1427e7e655ea1ba04195fabf151fbae5789a1 (patch) | |
tree | e27a45d05e261b8b68c417f029c6717b171811b4 /src/reflect | |
parent | d7fe04993e10750c308e44b0fe563bcd3b0714ad (diff) | |
parent | 20896646122fa82dc81f1405173b09eac37ae7cc (diff) | |
download | scala-95b1427e7e655ea1ba04195fabf151fbae5789a1.tar.gz scala-95b1427e7e655ea1ba04195fabf151fbae5789a1.tar.bz2 scala-95b1427e7e655ea1ba04195fabf151fbae5789a1.zip |
Merge pull request #5442 from adriaanm/t9943
SI-9943 sealed class does not yield SAM type
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/Definitions.scala | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 0f7cf07f08..fc7e184918 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -840,14 +840,14 @@ trait Definitions extends api.StandardDefinitions { * * The method must be monomorphic and have exactly one parameter list. * The class defining the method is a supertype of `tp` that - * has a public no-arg primary constructor. + * has a public no-arg primary constructor and it can be subclassed (not final or sealed). */ def samOf(tp: Type): Symbol = if (!doSam) NoSymbol else if (!isNonRefinementClassType(unwrapToClass(tp))) NoSymbol else { // look at erased type because we (only) care about what ends up in bytecode // (e.g., an alias type is fine as long as is compiles to a single-abstract-method) val tpSym: Symbol = erasure.javaErasure(tp).typeSymbol - if (tpSym.exists && tpSym.isClass + if (tpSym.exists && tpSym.isClass && !(tpSym hasFlag (FINAL | SEALED)) // if tp has a constructor (its class is not a trait), it must be public and must not take any arguments // (implementation restriction: implicit argument lists are excluded to simplify type inference in adaptToSAM) && { val ctor = tpSym.primaryConstructor |