| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The problem was the false assumption that methods specialized
on their type parameter, such as this one:
class Foo[@spec(Int) T](val x: T) {
def bar[@spec(Int) S >: T](f: S => S) = f(x)
}
have their normalized versions (`bar$mIc$sp`) never called
from the base specialization class `Foo`.
This meant that the implementation of `bar$mIc$sp` in `Foo`
simply threw an exception.
This assumption is not true, however. See this:
object Baz {
def apply[T]() = new Foo[T]
}
Calling `Baz.apply[Int]()` will create an instance of the
base specialization class `Foo` at `Int`.
Calling `bar` on this instance will be rewritten by
specialization to calling `bar$mIc$sp`, hence the error.
So, we have to emit a valid implementation for `bar`,
obviously.
Problem is, such an implementation would have conflicting
type bounds in the base specialization class `Foo`, since
we don't know if `T` is a subtype of `S = Int`.
In other words, we cannot emit:
def bar$mIc$sp(f: Int => Int) = f(x) // x: T
without typechecking errors.
However, notice that the bounds are valid if and only if
`T = Int`. In the same time, invocations of `bar$mIc$sp` will only
be emitted in callsites where the type bounds hold.
This means we can cast the expressions in method applications
to the required specialized type bound.
The following changes have been made:
1) The decision of whether or not to create a normalized
version of the specialized method is not done on the
`conflicting` relation anymore.
Instead, it's done based on the `satisfiable` relation,
which is true if there is possibly an instantiation of
the type parameters where the bounds hold.
2) The `satisfiable` method has a new variant called
`satisfiableConstraints`, which does unification to
figure out how the type parameters should be instantiated
in order to satisfy the bounds.
3) The `Duplicators` are changed to transform a tree
using the `castType` method which just returns the tree
by default.
In specialization, the `castType` in `Duplicators` is overridden,
and uses a map from type parameters to types.
This map is obtained by `satisfiableConstraints` from 2).
If the type of the expression is not equal to the expected type,
and this map contains a mapping to the expected type, then
the tree is cast, as discussed above.
Additional tests added.
Review by @dragos
Review by @VladUreche
Conflicts:
src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
src/compiler/scala/tools/nsc/typechecker/Duplicators.scala
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As usual, .tpe -> .tpeHK. As a side note following an old theme,
if symbols of type parameters knew that they were symbols of type
parameters, they could call tpeHK themselves rather than every call
site having to do it. It's the operation which injects dummies which
should require explicit programmer action, not the operation which
faithfully reproduces the unapplied type. Were it that way, errors could
be caught much more quickly via ill-kindedness.
Seems like an improvement over lurking compiler crashes at every call
to tparam.tpe.
|
|\
| |
| | |
Fix SI-4541.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Catch type errors when duplicating trees.
In this case, to access a protected member from a specialized
class is an error, so we would have to make the member public
anyway.
Better it is then to report an error and have the user make the
field public explicitly.
Review by @dragos.
|
|\ \
| | |
| | | |
Fix for java parser edge case.
|
| | |
| | |
| | |
| | | |
Empty statements are A-OK. Closes SI-5910. Review by @dragos.
|
|\ \ \
| | | |
| | | | |
enables reification of anonymous classes
|
| | |/
| |/| |
|
|\ \ \
| | | |
| | | | |
improve showRaw
|
| | |/
| |/|
| | |
| | | |
addresses concerns raised in http://groups.google.com/group/scala-user/browse_thread/thread/de5a5be2e083cf8e
|
|\ \ \
| | | |
| | | | |
SI-4270 Disqualify in scope implicits that are shadowed.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
If an expression wouldn't type check explicitly, it shouldn't be
allowed implicitly.
Employs typedIdent, which already does this sort of thing rather well,
instead of continuing to reimplement it in Implicits.
Remove check for non-implicit synonym, which is subsumed by typing an Ident.
Workaround Scaladoc oddity, by using an attributed select when the context
is deficient.
|
|\ \ \ \
| | | | |
| | | | | |
Adding copyInto and toVector methods to collections.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
* Move method into TraversableOnce from Iterator and Traversable to make the build pass.
* Udpate IDE tests with new collection methods.
* Rewire default toXYZ methods to use convertTo.
|
| | | | | |
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
* Fixed typo
* Renamed copyInto to copyTo
* Added tparam doc.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
* Added generic copyInto method for collections. For any collection with a CanBuildFrom, can convert a generic collection into it using the builder.
* Added specifici toVector method for collections. This is more efficient than copyInto if the collection is a Vector.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
Fix SI-4954.
|
| | |_|_|/
| |/| | |
| | | | |
| | | | |
| | | | |
| | | | | |
Override inner classes in `LinkedHashMap` that correspond
to `filterKeys`, `mapValues` and `keys` to retain a proper
ordering of elements when they are transformed.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
Use `ThreadLocalRandom` in `TrieMap.size`.
|
| |/ / / / |
|
|\ \ \ \ \
| |_|/ / /
|/| | | | |
CPS: enable return expressions in CPS code if they are in tail position
|
| | | | | |
|
| | |_|/
| |/| |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Adds a stack of context trees to AnnotationChecker(s). Here, it is used to
enforce that adaptAnnotations will only adapt the annotation of a return
expression if the expected type is a CPS type.
The remove-tail-return transform is reasonably general, covering cases such as
try-catch-finally. Moreover, an error is thrown if, in a CPS method, a return
is encountered which is not in a tail position such that it will be removed
subsequently.
|
|\ \ \ \
| |_|/ /
|/| | | |
Reverting the diagrams
|
| | | |
| | | |
| | | |
| | | | |
This reverts commit 831f09bb6d00c152bd8aef3ce8bf9e200080fe36.
|
|\| | |
| | | |
| | | | |
Diagrams in Scaladoc
|
| |/ /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This commit contains model changes required for adding class diagrams
to scaladoc. It also contains an improved implicit shadowing
computation, which hides the shadowed implicitly inherited members
from the main view and gives instructions on how to access them.
This is joint work with Damien Obrist (@damienobrist) on supporting
diagram generation in scaladoc, as part of Damien's semester project
in the LAMP laborarory at EPFL.
The full history is located at:
https://github.com/damienobrist/scala/tree/feature/diagrams-dev
Commit summary:
- diagrams model
- diagram settings (Settings.scala, ScalaDoc.scala)
- diagram model object (Entity.scala, Diagram.scala)
- model: tracking direct superclasses and subclasses,
implicit conversions from and to (ModelFactory.scala)
- diagram object computation (DiagramFactory.scala, DocFactory.scala)
- capacity to filter diagrams (CommentFactory.scala,
DiagramDirectiveParser.scala)
- diagram statistics object (DiagramStats.scala)
- delayed link evaluation (Body.scala, Comment.scala)
- tests
- improved implicits shadowing information
- model shadowing computation (ModelFactoryImplicitSupport.scala,
Entity.scala)
- html generation for shadowing information (Template.scala)
- tests
Also fixes an issue reported by @dragos, where single-line comment
expansion would lead to the comment disappearing.
Review by @kzys, @pedrofurla.
|
|/ / |
|
| |
| |
| |
| |
| | |
There doesn't seem to be any way to do that by adding
a synthetic annotation.
|
|\ \
| | |
| | | |
SI-5696 Detect excess constructor argument lists.
|
| | |
| | |
| | |
| | | |
An apply method fooled the usual mechanism.
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| | |
If the target method is defined in Java, treat the super reference
as an error, otherwise allow it in the knowledge that Scala loosens
the access restrictions on its generated classes.
Moves the test for that bug out of pending-ville. It's sufficient
to place Test in the empty package to exercise the right code paths.
|
|\ \
| | |
| | | |
SI-4831 Fix ambiguous import detection for renamed imports.
|
| |/ |
|
|\ \
| | |
| | | |
better unreachability for selections
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Consts are hashconsed modulo static-approximation-for-dynamic-value-equality
thus, two value-equality tests in patterns should reuse the same ValueConst
if and only if the tested values are guaranteed to be equal in all possible executions
the implementation uses unique types to track unique consts
for an Ident with a stable symbol, we simply use the corresponding singleton type
for a Select, we have to indirect some more: we store all the unique trees we've encountered and a unique type for each of them
this unique type is then used to find the uniqut const that approximates the run-time value
this may seem roundabout, but we need to standardize on types for representing "value" tests,
as a type test against a singleton type must give rise to the same ValueConst
as a value test using a tree that refers to the same symbol as the singleton type test
|
| | |
|
| | |
|
| | |
|
| | |
|
|/ |
|
|\
| |
| | |
SI-5167 An impl class method should refer to its own parameter symbols.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Rather than those of the original method in the trait.
If they are shared, parameter renaming in the implementaion class
is visible in the original method. This led to a crash in the resident
compiler when looking up the default argument getter.
|
|\ \
| | |
| | | |
SI-5652 Mangle names of potentially public lambda lifted methods.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This can happen if they are accessed from an inner class. If a
subclass is happens to lift a public method to the same name,
a VerifyError ensues.
The enclosed tests:
- demonstrate the absense of the VerifyError
- show the names generated for the lifted methods (which are
unchanged if not called from an inner class, or if lifted
into a trait implementation class.)
- ensure that the callers are rewritten to call the correct
method when multiple with the same name are lifted.
It's not ideal that this phase needs a priori knowledge of the
later phases to perform this mangling. A better fix would defer
this until the point when the methods are publicised, and leave
the unmangled private method in place and install an public,
mangled forwarder.
|
|\ \ \
| | | |
| | | | |
Fix SI-5853.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
This solves two issues.
First, up to now the newly generated symbols for normalized
members were not being added to the declaration list of the
owner during `specialize`. Now they are.
Second, during `extmethods`, the extension methods generated
get an additional curried parameter list for `$this`.
Trouble was, after that, during `uncurry` and before `specialize`,
these curried parameter lists were merged into one list.
Specialization afterwards treats extension methods just
like normal methods and generates new symbols without the
curried parameter list.
The `extensionMethod` now takes this into account by checking
if the first parameter of a potential extension method has
the name `$this`.
Review by @dragos.
Review by @odersky.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Reduce time spent in lubs by making depth more adaptive. It now takes into account separately the depth of the lub types and the maximal depth of theior base type sequences. It cuts depth more aggressively if it is the base types instead of the types themselves that grow deep.
The old truncation behavior is retained under option -Xfull-lubs
Another change is that we now track depth more precisely, which should also help or at least allow better statistics.
Also added statistics that measure #lubs and time spent in them.
|
| | | | |
|