File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -312,12 +312,12 @@ object desugar {
312
312
def productConstr (n : Int ) = {
313
313
val tycon = ref(defn.ProductNClass (n).typeRef)
314
314
val targs = constrVparamss.head map (_.tpt)
315
- AppliedTypeTree (tycon, targs)
315
+ if (targs.isEmpty) tycon else AppliedTypeTree (tycon, targs)
316
316
}
317
317
318
318
// Case classes get a ProductN parent
319
319
var parents1 = parents
320
- if ((mods is Case ) && 2 <= arity && arity <= Definitions .MaxTupleArity )
320
+ if ((mods is Case ) && arity <= Definitions .MaxTupleArity )
321
321
parents1 = parents1 :+ productConstr(arity)
322
322
323
323
// The thicket which is the desugared version of the companion object
Original file line number Diff line number Diff line change @@ -394,7 +394,7 @@ class Definitions {
394
394
lazy val Function0_apply = FunctionClass (0 ).requiredMethod(nme.apply)
395
395
396
396
lazy val TupleClass = mkArityArray(" scala.Tuple" , MaxTupleArity , 2 )
397
- lazy val ProductNClass = mkArityArray(" scala.Product" , MaxTupleArity , 2 )
397
+ lazy val ProductNClass = mkArityArray(" scala.Product" , MaxTupleArity , 0 )
398
398
399
399
lazy val FunctionClasses : Set [Symbol ] = FunctionClass .toSet
400
400
lazy val TupleClasses : Set [Symbol ] = TupleClass .toSet
Original file line number Diff line number Diff line change
1
+ /* __ *\
2
+ ** ________ ___ / / ___ Scala API **
3
+ ** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
4
+ ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
5
+ ** /____/\___/_/ |_/____/_/ | | **
6
+ ** |/ **
7
+ \* */
8
+ package scala
9
+
10
+ /** A class for Product0 which was missing from the scala distribution. */
11
+ object Product0 {
12
+ def unapply (x : Product0 ): Option [Product0 ] =
13
+ Some (x)
14
+ }
15
+
16
+ trait Product0 extends Any with Product {
17
+
18
+ override def productArity = 0
19
+
20
+ @ throws(classOf [IndexOutOfBoundsException ])
21
+ override def productElement (n : Int ) =
22
+ throw new IndexOutOfBoundsException (n.toString())
23
+ }
24
+
You can’t perform that action at this time.
0 commit comments