-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove Any from the inheritance chain
this fixes #323
- Loading branch information
Showing
6 changed files
with
50 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
declare var a: Object; | ||
|
||
declare function foo(o: Object): Object | ||
declare function foo(o: Object): Object | ||
|
||
interface SomeClass extends Object {} |
38 changes: 38 additions & 0 deletions
38
model-lowerings/src/org/jetbrains/dukat/commonLowerings/removeParentAny.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.jetbrains.dukat.commonLowerings | ||
|
||
import org.jetbrains.dukat.astCommon.IdentifierEntity | ||
import org.jetbrains.dukat.astCommon.QualifierEntity | ||
import org.jetbrains.dukat.astModel.ClassLikeModel | ||
import org.jetbrains.dukat.astModel.ClassModel | ||
import org.jetbrains.dukat.astModel.HeritageModel | ||
import org.jetbrains.dukat.astModel.InterfaceModel | ||
import org.jetbrains.dukat.astModel.ModuleModel | ||
import org.jetbrains.dukat.astModel.TypeValueModel | ||
import org.jetbrains.dukat.model.commonLowerings.ModelLowering | ||
import org.jetbrains.dukat.model.commonLowerings.TopLevelModelLowering | ||
import org.jetbrains.dukat.ownerContext.NodeOwner | ||
import org.jetbrains.dukat.stdlib.TSLIBROOT | ||
|
||
private fun TypeValueModel.isAny() = fqName == QualifierEntity(TSLIBROOT, IdentifierEntity("Any")) | ||
|
||
private fun ClassLikeModel.removeParentAny(): List<HeritageModel> { | ||
return parentEntities.filter { !it.value.isAny() } | ||
} | ||
|
||
private class RemoveParentAnyLowering : TopLevelModelLowering { | ||
override fun lowerClassModel(ownerContext: NodeOwner<ClassModel>, parentModule: ModuleModel): ClassModel? { | ||
val node = ownerContext.node | ||
return super.lowerClassModel(ownerContext.copy(node = node.copy(parentEntities = node.removeParentAny())), parentModule) | ||
} | ||
|
||
override fun lowerInterfaceModel(ownerContext: NodeOwner<InterfaceModel>, parentModule: ModuleModel): InterfaceModel? { | ||
val node = ownerContext.node | ||
return super.lowerInterfaceModel(ownerContext.copy(node = node.copy(parentEntities = node.removeParentAny())), parentModule) | ||
} | ||
} | ||
|
||
class RemoveParentAny : ModelLowering { | ||
override fun lower(module: ModuleModel): ModuleModel { | ||
return RemoveParentAnyLowering().lowerRoot(module, NodeOwner(module, null)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters