File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed
compiler/scala/tools/nsc/transform/patmat
reflect/scala/reflect/internal Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -172,7 +172,6 @@ trait TreeAndTypeAnalysis extends Debugging {
172
172
// a type is "uncheckable" (for exhaustivity) if we don't statically know its subtypes (i.e., it's unsealed)
173
173
// we consider tuple types with at least one component of a checkable type as a checkable type
174
174
def uncheckableType (tp : Type ): Boolean = {
175
- def tupleComponents (tp : Type ) = tp.normalize.typeArgs
176
175
val checkable = (
177
176
(isTupleType(tp) && tupleComponents(tp).exists(tp => ! uncheckableType(tp)))
178
177
|| enumerateSubtypes(tp).nonEmpty)
Original file line number Diff line number Diff line change @@ -653,6 +653,7 @@ trait Definitions extends api.StandardDefinitions {
653
653
// tends to change the course of events by forcing types.
654
654
def isFunctionType (tp : Type ) = isFunctionTypeDirect(tp.dealiasWiden)
655
655
def isTupleType (tp : Type ) = isTupleTypeDirect(tp.dealiasWiden)
656
+ def tupleComponents (tp : Type ) = tp.dealiasWiden.typeArgs
656
657
657
658
lazy val ProductRootClass : ClassSymbol = requiredClass[scala.Product ]
658
659
def Product_productArity = getMemberMethod(ProductRootClass , nme.productArity)
@@ -837,7 +838,7 @@ trait Definitions extends api.StandardDefinitions {
837
838
def typeOfMemberNamedApply (tp : Type ) = typeArgOfBaseTypeOr(tp, SeqClass )(resultOfMatchingMethod(tp, nme.apply)(IntTpe ))
838
839
def typeOfMemberNamedDrop (tp : Type ) = typeArgOfBaseTypeOr(tp, SeqClass )(resultOfMatchingMethod(tp, nme.drop)(IntTpe ))
839
840
def typesOfSelectors (tp : Type ) =
840
- if (isTupleType(tp)) tp.typeArgs
841
+ if (isTupleType(tp)) tupleComponents(tp)
841
842
else getterMemberTypes(tp, productSelectors(tp))
842
843
843
844
// SI-8128 Still using the type argument of the base type at Seq/Option if this is an old-style (2.10 compatible)
Original file line number Diff line number Diff line change
1
+ class CC (val i : Int , val s : String )
2
+ object CC extends {
3
+ type P = (Int , String )
4
+
5
+ // def unapply(c: CC): Option[(Int, String)] = Some((c.i, c.s)) // OK
6
+ def unapply (c : CC ): Option [P ] = Some ((c.i, c.s)) // fails (because of the type alias)
7
+ }
8
+
9
+ class Test {
10
+ val cc = new CC (23 , " foo" )
11
+ val CC (i, s) = cc
12
+ }
You can’t perform that action at this time.
0 commit comments