| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
This commit drops about 700 lines of redundant traversal logic.
There had been ad hoc adjustments to the pickling scheme here and
there, probably in pursuit of tiny performance improvements.
For instance, a Block was pickled expr/stats instead of stats/expr,
a TypeDef was pickled rhs/tparams instead of tparams/rhs.
The benefits derived are invisible compared to the cost of having
several hundred lines of tree traversal code duplicated in half a
dozen or more places.
After making Traverser consistent/complete, it was a straightforward
matter to use it for pickling. It is ALSO now possible to write a
vastly cleaner tree printer than the ones presently in trunk, but I
leave this as an exercise for Dear Reviewer.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
There's a huge amount of tree traversal related duplication
which is hard to eliminate only because trees aren't properly
traversed. The not-quite-tree bits of key trees are ignored
during traversals, making it impossible to write e.g. a
pretty printer without duplicating almost the entire traversal
logic (as indeed is done for printing purposes in more than one
place.) And almost the entire pickler logic is redundant with
Traverser, except since it's all duplicated of course it diverged.
The pickler issue is remedied in the commit to follow.
The not-quite-trees not quite being traversed were Modifiers, Name,
ImportSelector, and Constant. Now every case field of every tree is
traversed, with classes which aren't trees traversed via the following
methods, default implementations as shown:
def traverseName(name: Name): Unit = ()
def traverseConstant(c: Constant): Unit = ()
def traverseImportSelector(sel: ImportSelector): Unit = ()
def traverseModifiers(mods: Modifiers): Unit = traverseAnnotations(mods.annotations)
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
This enables a measure of "command/query separation", which is
to say: the same method shouldn't go on a side effecting binge
and also return a value.
|
| | | | |
|
| | | | |
|
|\ \ \ \
| |_|_|/
|/| | | |
[resubmit] Experimental Single Abstract Method support (sammy meets world)
|
| |\| |
| | | |
| | | |
| | | |
| | | | |
Conflicts:
src/compiler/scala/tools/nsc/typechecker/Typers.scala
|
| | | |
| | | |
| | | |
| | | | |
Addressing review feedback.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
`synthesizeSAMFunction` will be used to expand the following tree:
```
{ (p1: T1, ..., pN: TN) => body } : S
```
to:
```
{
def apply$body(p1: T1, ..., pN: TN): T = body
new S { def apply(p1: T1, ..., pN: TN): T = apply$body(p1,..., pN) }
}
```
The expansion assumes `S` (the expected type) defines a single abstract method
(let's call that method `apply` for simplicity).
1. If 'T' is not fully defined, it is inferred by type checking
`def apply$body` without a result type before type checking the block.
The method's inferred result type is used instead of T`.
[See test/files/pos/sammy_poly.scala]
2. To more easily enforce S's members are not in scope in `body`, that tree
goes to the `apply$body` method that's outside the anonymous subclass of S.
(The separate `apply$body` method simplifies the implementation of 1&2.)
3. The following restrictions apply to S:
1. Its primary constructor (if any) must be public, no-args, not overloaded.
2. S must have exactly one abstract member, its SAM
3. SAM must take exactly one argument list
4. SAM must be monomorphic
We may later relax these requirements to allow an implicit argument list,
both on the constructor and the SAM. Could also let the SAM be polymorphic.
|
| | | |
| | | |
| | | |
| | | |
| | | | |
When looking for deferred members, it only makes sense
to retry when deferred members aren't excluded.
|
| |/ /
|/| |
| | |
| | |
| | |
| | | |
As long as it's a block of pure boilerplate we have to
navigate around all the time, it may as well be the most
beautiful boilerplate it knows how to be.
|
|\ \ \
| | | |
| | | | |
SI-7902 Fix spurious kind error due to an unitialized symbol
|
| |/ /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Tracked down this error:
<none> is invariant, but type Y2 is declared covariant
<none>'s bounds<notype> are stricter than type X2's declared bounds >: Nothing <: Any, <none>'s bounds<notype> are stricter than type Y2's declared bounds >: Nothing <: Any
to `Symbol#typeParams` returning `List(NoSymbol)` if the symbol
was not initialized.
This happends in the enclosed test for:
// checkKindBoundsHK()
hkArgs = List(type M3)
hkParams = List(type M2)
This commit forces the symbol of the higher-kinded type argument
before checking kind conformance.
A little backstory:
The `List(NoSymbol)` arises from:
class PolyTypeCompleter... {
// @M. If `owner` is an abstract type member, `typeParams` are all NoSymbol (see comment in `completerOf`),
// otherwise, the non-skolemized (external) type parameter symbols
override val typeParams = tparams map (_.symbol)
The variation that triggers this problem gets into the kind
conformance checks quite early on, during naming of:
private[this] val x = ofType[InSeq]
The inferred type of which is forced during:
def addDerivedTrees(typer: Typer, stat: Tree): List[Tree] = stat match {
case vd @ ValDef(mods, name, tpt, rhs) if !noFinishGetterSetter(vd) =>
// If we don't save the annotations, they seem to wander off.
val annotations = stat.symbol.initialize.annotations
|
|\ \ \
| |_|/
|/| | |
Extract isStable and isVolatile from Type.
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
As with finalResultType, this is easier to control
and WAY easier to understand. Look, all the relevant
code fits on half a screenful rather than being
spread out over 5000 lines and you have to be
constantly conscious of what is overriding what.
Truly it would be hard to damn the indiscriminate
use of subtype polymorphism any more soundly than
does this, by way of contrast:
def isStable(tp: Type): Boolean = tp match {
case _: SingletonType => true
case NoPrefix => true
case TypeRef(_, NothingClass | SingletonClass, _) => true
case TypeRef(_, sym, _) if sym.isAbstractType => tp.bounds.hi.typeSymbol isSubClass SingletonClass
case TypeRef(pre, sym, _) if sym.isModuleClass => isStable(pre)
case TypeRef(_, _, _) if tp ne tp.dealias => isStable(tp.dealias)
case TypeVar(origin, _) => isStable(origin)
case AnnotatedType(_, atp, _) => isStable(atp) // Really?
case _: SimpleTypeProxy => isStable(tp.underlying)
case _ => false
}
That's all of it! If there are bugs in it (of course there are)
some might even be found now.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Increases your chance of knowing what is going on in
OverridingPairs. Introduces some new abstractions which I
hope for your own sakes you will put to use in some way:
RelativeTo: operations relative to a prefix
SymbolPair: two symbols being compared for something, and
the enclosing class where the comparison is being performed
Fixed a minor bug with access by accident by way of more
principled pair analysis. See run/private-override.scala.
Upgraded the error message issued on certain conflicts
to give the line numbers of both conflicting methods, as
opposed to just one and you go hunting.
|
|\
| |
| | |
Rework cff8b569 to heal the windows build.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
- change newTermName to fix negative length names
rather than reject them
- restore the old logic in unspecializedName for names that
result from AnyRef specialized type parameters.
Why does fix the windows build? I remain none the wiser.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously it was enough to just extend scala.reflect.macros.Macro, which
created some loopholes, but now scalac enforces that bundles:
1) Are static (not necessarily top-level, but just static)
2) Are traits (objects shouldn't be bundles anyway, and classes bring
complications with their ctors which require special treatment in
generated classes, so why support them if they don't bring anything
new to the table?)
3) Are monomorphic (again, this brings unnecessary complications wrt
auxiliary code generation, so I don't see merit in supporting
polymorphic bundles, whatever that a polymorphic bundle could mean)
4) Don't provide concrete implementation for Macro.c (if they do then
what is the point?)
|
|
|
|
|
|
|
| |
Most of this was revealed via -Xlint with a flag which assumes
closed world. I can't see how to check the assumes-closed-world
code in without it being an ordeal. I'll leave it in a branch in
case anyone wants to finish the long slog to the merge.
|
|
|
|
|
| |
This is the change which broke the compiler until I made the
changes found in 693ecffbaf.
|
|\
| |
| | |
Updating Position call sites.
|
| |
| |
| |
| |
| |
| | |
Calling position factories rather than instantiating these
particular classes. Not calling deprecated methods. Added a few
position combinator methods.
|
|\ \
| | |
| | | |
transformers no longer ignore UnApply.fun
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Second time's the charm. I remember trying to do exactly the same somewhen
around 2.10.0-M4, but then some continuations tests were failing.
Luckily, today everything went smoothly.
Please note that this fix changes the way that SI-5465 manifests itself.
Previously it produced type errors, now it simply crashes the compiler.
Therefore I had to attach the try/catch FatalError clause to invocations
of toolbox methods, so that compiler crashes get caught and translated to
ToolBoxErrors.
Also fixes SI-7871, and that clears the way for implementing quasiquotes
with conventional macros rather than relying on a special case in typer.
|
| |/
|/|
| |
| |
| |
| |
| | |
I had covered a few more cases working on this recently.
The warnings in several more cases involving polymorphism,
currying, and selects vs. idents receive more refined
handling.
|
|\ \
| | |
| | | |
SI-6762 rename emptyValDef to emptySelfType.
|
| | |
| | |
| | |
| | |
| | | |
Looks like emptyValDef.isEmpty was already changed to return
false, so now all that's left is a name which means something.
|
|\ \ \
| | | |
| | | | |
Fix up DEFAULTPARAM semantics.
|
| |/ /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
I foolishly believed the deprecation message on "hasDefaultFlag"
which suggested I use "hasDefault" instead. After lots of head
scratching, I hardened the semantics so it's like this:
- A method parameter with a default value is PARAM | DEFAULTPARAM
- A default getter for such a parameter is METHOD | DEFAULTPARAM
- And "hasDefault" is has(DEFAULTPARAM) && has(PARAM | METHOD)
Why all the bonus logic, why not just hasFlag(DEFAULTPARAM)? For
some reason we have a handful of overloaded flags spanning uses
which someone apparently thinks can never intersect but I have
not been so lucky overall. So since DEFAULTPARAM is overloaded with
TRAIT, unless we think it's fine that default getters and method
parameters with defaults will pose as traits all the time, there
has to be an anchor bit alongside it.
|
|\ \ \
| |/ /
|/| |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Conflicts:
bincompat-backward.whitelist.conf
bincompat-forward.whitelist.conf
build.xml
src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
src/library/scala/concurrent/Future.scala
src/reflect/scala/reflect/internal/Types.scala
|
| |\ \
| | | |
| | | | |
SI-7815 Dealias before deeming method type as dependent
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
To enable eta-expansion of method types seen from a prefix that
renders the result type as independent from the parameter symbols.
The enclosed test shows that we dealias types before checking
dependence, and that we do this deeply (e.g. type arguments are
also dealised.)
An existing test, neg/error_dependentMethodTpeConversionToFunction,
confirms that bona-fide dependent methods are still prohibited from
eta expansion.
|
| |/ /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
A class should not be required to implement a Java default method.
This commit uses `isDeferredNotDefault` in place of `isDeferred`
when finding unimplemented methods.
The test itself does not depend on Java 8 as we use scalac's
Java source parser to set things up.
|
| |/
|/|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
`isFunctionType` and `isTupleType` started returing true for
type constructors as of aeb73314. This led to a crash in type
printing in ScalaDoc (specfically, in ModelFactoryTypeSupport.scala)
This commit:
- fixes those methods by guarding with !isHigherKinded
- unit tests said methods
- tests the reported crasher with a ScalaDoc test.
|
|\ \
| | |
| | | |
Revert #2957
|
| | |
| | |
| | |
| | |
| | | |
This reverts commit 884e1ce762d98b29594146d37b85384581d9ba96, reversing
changes made to f6fcc4431f272c707d49de68add532c452dd4b0f.
|
|\ \ \
| |/ /
|/| | |
SI-7868 Account for numeric widening in match translation
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Pattern match translation was unprepared for trees of the shape:
(0: Short) match {
case A.unapply(<unapply-selector>.toInt) <unapply> (_) => ()
case _ => ()
}
While a scrutinee is inelibigle for implicit views in order to
conform to the type of the extractor call, it is allowed to
weakly conform. In this case, the typechecker will add the
numeric widening with a `toInt` call.
This commit:
- Changes treeInfo.Unapplied to recognize this tree shape
- Changes spliceApply to recognize and preserve the widening
when substituting the unapply selector with the binder
- Tests reification of such pattern matches, which also depends
on treeInfo.Unapplied.
|
|\ \ \
| |/ /
|/| | |
Quasiquotes: add syntactic extractor for assignment-like trees
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
There are three kinds of assign-like trees:
1. Assign(lhs, rhs) // $lhs = $rhs
3. AssignOrNamedArg(lhs, rhs) // $lhs = $rhs
2. Apply(Select(f, nme.update), args :+ rhs) // $f(..$args) = $rhs
New syntactic combinator unifies all of them and lets users not to think
about these implementations details.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The parser hole I found while working on the generated positions
serves as the umbrella for a host of improvements. Upgraded
positions assigned during some specific challenging situations mostly
involving the creation of synthetic trees, e.g. for comprehensions
and closures. While doing so improved some error messages.
Eliminated some of the most glaring duplication in the parser.
It's written like there is some payoff associated with being
spectacularly imperative. Not so far.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Can't ensure range position points are meaningful when we never
see them. To limit noise, only print the point when it != start.
[x:y] // point=x, start=x, end=y
[p/x:y] // point=p, start=x, end=y
I'm open to a different syntax.
Also prints NoPosition as [X] rather than [NoPosition] because
noise is for construction workers and attenders of rock concerts.
Some range position and parser tests are included so we can see
the checkfile change when the forthcoming fix happens (either an
error message improvement or a positional one.)
|
|\ \ \
| | | |
| | | | |
Type housekeeping.
|
| |/ /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Moved ListOfNil somewhere more generally accessible. No
reason the compiler should hoard it for itself. Flitted
to a few locations with constructs like ".head.head" and
".tail.head" looking for code which could be rewritten. Found
some, admittedly not always making use of ListOfNil.
Made overdue moves of ConstantType(Constant(true|false|null))
to vals in Definitions.
|
|\ \ \
| |/ /
|/| | |
Cull extraneous whitespace.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
One last flurry with the broom before I leave you slobs to code
in your own filth. Eliminated all the trailing whitespace I
could manage, with special prejudice reserved for the test cases
which depended on the preservation of trailing whitespace.
Was reminded I cannot figure out how to eliminate the trailing
space on the "scala> " prompt in repl transcripts. At least
reduced the number of such empty prompts by trimming transcript
code on the way in.
Routed ConsoleReporter's "printMessage" through a trailing
whitespace stripping method which might help futureproof
against the future of whitespace diseases. Deleted the up-to-40
lines of trailing whitespace found in various library files.
It seems like only yesterday we performed whitespace surgery
on the whole repo. Clearly it doesn't stick very well. I suggest
it would work better to enforce a few requirements on the way in.
|
|\ \ \
| |/ /
|/| | |
SI-7853 Regression in explicit outer
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Rather than localizing the fix to the outerAccessor, this
commit pushed the call to `memberType` into *all* usages of
`newValDef` and `newDefDef`.
The TPT of `applyOrElse` in synthetized partial functions must
be set explicitly to pass the pos/t7853-partial-function.scala.
Otherwise, the as-seen-from ends up cloning the type parameter
`B1` of `applyOrElse` as it transforms (questionably)
its bound from `List[Int @unchecked]` to `List[Int]`.
Partial Function synthesis was already a delicate area, and this
makes things more explicit which could be counted as an improvement.
|
|\ \ \
| |/ /
|/| | |
Damage control related to AnyRef specialization
|