diff --git a/.idea/dictionaries/Nikolay_Krasko.xml b/.idea/dictionaries/Nikolay_Krasko.xml
new file mode 100644
index 00000000000..f882fb4f9b5
--- /dev/null
+++ b/.idea/dictionaries/Nikolay_Krasko.xml
@@ -0,0 +1,10 @@
+
+
+
+ kdoc
+ redeclarations
+ subclassed
+ subgraph
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/idea_default.xml b/.idea/inspectionProfiles/idea_default.xml
index 2b82dfd963c..42c64a58316 100644
--- a/.idea/inspectionProfiles/idea_default.xml
+++ b/.idea/inspectionProfiles/idea_default.xml
@@ -59,6 +59,9 @@
+
+
+
diff --git a/android-sdk-annotations/android/accessibilityservice/annotations.xml b/android-sdk-annotations/android/accessibilityservice/annotations.xml
new file mode 100644
index 00000000000..9b98b61de2f
--- /dev/null
+++ b/android-sdk-annotations/android/accessibilityservice/annotations.xml
@@ -0,0 +1,23 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/accounts/annotations.xml b/android-sdk-annotations/android/accounts/annotations.xml
new file mode 100644
index 00000000000..9cf8d0b8363
--- /dev/null
+++ b/android-sdk-annotations/android/accounts/annotations.xml
@@ -0,0 +1,122 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/animation/annotations.xml b/android-sdk-annotations/android/animation/annotations.xml
new file mode 100644
index 00000000000..75b0c657d7c
--- /dev/null
+++ b/android-sdk-annotations/android/animation/annotations.xml
@@ -0,0 +1,245 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/annotations.xml b/android-sdk-annotations/android/annotations.xml
new file mode 100644
index 00000000000..dcfa0be771d
--- /dev/null
+++ b/android-sdk-annotations/android/annotations.xml
@@ -0,0 +1,482 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+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 -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/app/admin/annotations.xml b/android-sdk-annotations/android/app/admin/annotations.xml
new file mode 100644
index 00000000000..7bd01b15c7c
--- /dev/null
+++ b/android-sdk-annotations/android/app/admin/annotations.xml
@@ -0,0 +1,71 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/app/annotations.xml b/android-sdk-annotations/android/app/annotations.xml
new file mode 100644
index 00000000000..3ee7d0ed7a1
--- /dev/null
+++ b/android-sdk-annotations/android/app/annotations.xml
@@ -0,0 +1,1382 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+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
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/app/backup/annotations.xml b/android-sdk-annotations/android/app/backup/annotations.xml
new file mode 100644
index 00000000000..d865378ddc1
--- /dev/null
+++ b/android-sdk-annotations/android/app/backup/annotations.xml
@@ -0,0 +1,56 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/appwidget/annotations.xml b/android-sdk-annotations/android/appwidget/annotations.xml
new file mode 100644
index 00000000000..20c35c2d587
--- /dev/null
+++ b/android-sdk-annotations/android/appwidget/annotations.xml
@@ -0,0 +1,122 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/bluetooth/annotations.xml b/android-sdk-annotations/android/bluetooth/annotations.xml
new file mode 100644
index 00000000000..5ababfffabd
--- /dev/null
+++ b/android-sdk-annotations/android/bluetooth/annotations.xml
@@ -0,0 +1,155 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/content/annotations.xml b/android-sdk-annotations/android/content/annotations.xml
new file mode 100644
index 00000000000..05fb4a96d92
--- /dev/null
+++ b/android-sdk-annotations/android/content/annotations.xml
@@ -0,0 +1,1508 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+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
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/content/pm/annotations.xml b/android-sdk-annotations/android/content/pm/annotations.xml
new file mode 100644
index 00000000000..b459da13da2
--- /dev/null
+++ b/android-sdk-annotations/android/content/pm/annotations.xml
@@ -0,0 +1,338 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/content/res/annotations.xml b/android-sdk-annotations/android/content/res/annotations.xml
new file mode 100644
index 00000000000..829e62db0f5
--- /dev/null
+++ b/android-sdk-annotations/android/content/res/annotations.xml
@@ -0,0 +1,134 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/database/annotations.xml b/android-sdk-annotations/android/database/annotations.xml
new file mode 100644
index 00000000000..64acee34fa1
--- /dev/null
+++ b/android-sdk-annotations/android/database/annotations.xml
@@ -0,0 +1,320 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/database/sqlite/annotations.xml b/android-sdk-annotations/android/database/sqlite/annotations.xml
new file mode 100644
index 00000000000..474be512e5c
--- /dev/null
+++ b/android-sdk-annotations/android/database/sqlite/annotations.xml
@@ -0,0 +1,104 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/drm/annotations.xml b/android-sdk-annotations/android/drm/annotations.xml
new file mode 100644
index 00000000000..6b2edc40397
--- /dev/null
+++ b/android-sdk-annotations/android/drm/annotations.xml
@@ -0,0 +1,32 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/gesture/annotations.xml b/android-sdk-annotations/android/gesture/annotations.xml
new file mode 100644
index 00000000000..4a8e94217e9
--- /dev/null
+++ b/android-sdk-annotations/android/gesture/annotations.xml
@@ -0,0 +1,131 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/graphics/annotations.xml b/android-sdk-annotations/android/graphics/annotations.xml
new file mode 100644
index 00000000000..02d45da29d9
--- /dev/null
+++ b/android-sdk-annotations/android/graphics/annotations.xml
@@ -0,0 +1,239 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/graphics/drawable/annotations.xml b/android-sdk-annotations/android/graphics/drawable/annotations.xml
new file mode 100644
index 00000000000..02a2dfec34d
--- /dev/null
+++ b/android-sdk-annotations/android/graphics/drawable/annotations.xml
@@ -0,0 +1,89 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/hardware/annotations.xml b/android-sdk-annotations/android/hardware/annotations.xml
new file mode 100644
index 00000000000..164924d635d
--- /dev/null
+++ b/android-sdk-annotations/android/hardware/annotations.xml
@@ -0,0 +1,239 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/hardware/display/annotations.xml b/android-sdk-annotations/android/hardware/display/annotations.xml
new file mode 100644
index 00000000000..5c4ddc3a9a1
--- /dev/null
+++ b/android-sdk-annotations/android/hardware/display/annotations.xml
@@ -0,0 +1,11 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/hardware/input/annotations.xml b/android-sdk-annotations/android/hardware/input/annotations.xml
new file mode 100644
index 00000000000..327463d9206
--- /dev/null
+++ b/android-sdk-annotations/android/hardware/input/annotations.xml
@@ -0,0 +1,11 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/hardware/usb/annotations.xml b/android-sdk-annotations/android/hardware/usb/annotations.xml
new file mode 100644
index 00000000000..b6d00e5b249
--- /dev/null
+++ b/android-sdk-annotations/android/hardware/usb/annotations.xml
@@ -0,0 +1,71 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/inputmethodservice/annotations.xml b/android-sdk-annotations/android/inputmethodservice/annotations.xml
new file mode 100644
index 00000000000..e2bad5b4fad
--- /dev/null
+++ b/android-sdk-annotations/android/inputmethodservice/annotations.xml
@@ -0,0 +1,173 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/location/annotations.xml b/android-sdk-annotations/android/location/annotations.xml
new file mode 100644
index 00000000000..5fe2d948d3a
--- /dev/null
+++ b/android-sdk-annotations/android/location/annotations.xml
@@ -0,0 +1,35 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/media/annotations.xml b/android-sdk-annotations/android/media/annotations.xml
new file mode 100644
index 00000000000..657e37bcdd6
--- /dev/null
+++ b/android-sdk-annotations/android/media/annotations.xml
@@ -0,0 +1,179 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/media/audiofx/annotations.xml b/android-sdk-annotations/android/media/audiofx/annotations.xml
new file mode 100644
index 00000000000..b7eecd69e99
--- /dev/null
+++ b/android-sdk-annotations/android/media/audiofx/annotations.xml
@@ -0,0 +1,26 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/media/effect/annotations.xml b/android-sdk-annotations/android/media/effect/annotations.xml
new file mode 100644
index 00000000000..bed3b6dcae7
--- /dev/null
+++ b/android-sdk-annotations/android/media/effect/annotations.xml
@@ -0,0 +1,83 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/net/annotations.xml b/android-sdk-annotations/android/net/annotations.xml
new file mode 100644
index 00000000000..031101e8123
--- /dev/null
+++ b/android-sdk-annotations/android/net/annotations.xml
@@ -0,0 +1,320 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/net/http/annotations.xml b/android-sdk-annotations/android/net/http/annotations.xml
new file mode 100644
index 00000000000..bb6827c1f0b
--- /dev/null
+++ b/android-sdk-annotations/android/net/http/annotations.xml
@@ -0,0 +1,47 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/net/nsd/annotations.xml b/android-sdk-annotations/android/net/nsd/annotations.xml
new file mode 100644
index 00000000000..853b32b5c83
--- /dev/null
+++ b/android-sdk-annotations/android/net/nsd/annotations.xml
@@ -0,0 +1,17 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/net/sip/annotations.xml b/android-sdk-annotations/android/net/sip/annotations.xml
new file mode 100644
index 00000000000..b687fe84911
--- /dev/null
+++ b/android-sdk-annotations/android/net/sip/annotations.xml
@@ -0,0 +1,11 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/net/wifi/annotations.xml b/android-sdk-annotations/android/net/wifi/annotations.xml
new file mode 100644
index 00000000000..ce007264d94
--- /dev/null
+++ b/android-sdk-annotations/android/net/wifi/annotations.xml
@@ -0,0 +1,125 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/net/wifi/p2p/annotations.xml b/android-sdk-annotations/android/net/wifi/p2p/annotations.xml
new file mode 100644
index 00000000000..ba43eeebd8b
--- /dev/null
+++ b/android-sdk-annotations/android/net/wifi/p2p/annotations.xml
@@ -0,0 +1,47 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/net/wifi/p2p/nsd/annotations.xml b/android-sdk-annotations/android/net/wifi/p2p/nsd/annotations.xml
new file mode 100644
index 00000000000..c35eb7feaf0
--- /dev/null
+++ b/android-sdk-annotations/android/net/wifi/p2p/nsd/annotations.xml
@@ -0,0 +1,8 @@
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/nfc/annotations.xml b/android-sdk-annotations/android/nfc/annotations.xml
new file mode 100644
index 00000000000..a5c951e89a6
--- /dev/null
+++ b/android-sdk-annotations/android/nfc/annotations.xml
@@ -0,0 +1,56 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/nfc/tech/annotations.xml b/android-sdk-annotations/android/nfc/tech/annotations.xml
new file mode 100644
index 00000000000..9575f22d273
--- /dev/null
+++ b/android-sdk-annotations/android/nfc/tech/annotations.xml
@@ -0,0 +1,56 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/opengl/annotations.xml b/android-sdk-annotations/android/opengl/annotations.xml
new file mode 100644
index 00000000000..d68a5c67d84
--- /dev/null
+++ b/android-sdk-annotations/android/opengl/annotations.xml
@@ -0,0 +1,8 @@
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/os/annotations.xml b/android-sdk-annotations/android/os/annotations.xml
new file mode 100644
index 00000000000..243c9871f5d
--- /dev/null
+++ b/android-sdk-annotations/android/os/annotations.xml
@@ -0,0 +1,548 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+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
+
+
diff --git a/android-sdk-annotations/android/preference/annotations.xml b/android-sdk-annotations/android/preference/annotations.xml
new file mode 100644
index 00000000000..0a76aa87d07
--- /dev/null
+++ b/android-sdk-annotations/android/preference/annotations.xml
@@ -0,0 +1,344 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/provider/annotations.xml b/android-sdk-annotations/android/provider/annotations.xml
new file mode 100644
index 00000000000..1265fc81ab3
--- /dev/null
+++ b/android-sdk-annotations/android/provider/annotations.xml
@@ -0,0 +1,3611 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
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+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/renderscript/annotations.xml b/android-sdk-annotations/android/renderscript/annotations.xml
new file mode 100644
index 00000000000..ffa6a355cd7
--- /dev/null
+++ b/android-sdk-annotations/android/renderscript/annotations.xml
@@ -0,0 +1,320 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/security/annotations.xml b/android-sdk-annotations/android/security/annotations.xml
new file mode 100644
index 00000000000..af2e35ec98d
--- /dev/null
+++ b/android-sdk-annotations/android/security/annotations.xml
@@ -0,0 +1,14 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/service/dreams/annotations.xml b/android-sdk-annotations/android/service/dreams/annotations.xml
new file mode 100644
index 00000000000..2c05d018f33
--- /dev/null
+++ b/android-sdk-annotations/android/service/dreams/annotations.xml
@@ -0,0 +1,35 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/service/textservice/annotations.xml b/android-sdk-annotations/android/service/textservice/annotations.xml
new file mode 100644
index 00000000000..76d6ad5468e
--- /dev/null
+++ b/android-sdk-annotations/android/service/textservice/annotations.xml
@@ -0,0 +1,14 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/service/wallpaper/annotations.xml b/android-sdk-annotations/android/service/wallpaper/annotations.xml
new file mode 100644
index 00000000000..b78b5b2e27a
--- /dev/null
+++ b/android-sdk-annotations/android/service/wallpaper/annotations.xml
@@ -0,0 +1,23 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/speech/annotations.xml b/android-sdk-annotations/android/speech/annotations.xml
new file mode 100644
index 00000000000..5baff6bbc92
--- /dev/null
+++ b/android-sdk-annotations/android/speech/annotations.xml
@@ -0,0 +1,131 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/speech/tts/annotations.xml b/android-sdk-annotations/android/speech/tts/annotations.xml
new file mode 100644
index 00000000000..0fbaa39db1f
--- /dev/null
+++ b/android-sdk-annotations/android/speech/tts/annotations.xml
@@ -0,0 +1,77 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/telephony/annotations.xml b/android-sdk-annotations/android/telephony/annotations.xml
new file mode 100644
index 00000000000..f688c5ef93f
--- /dev/null
+++ b/android-sdk-annotations/android/telephony/annotations.xml
@@ -0,0 +1,68 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/telephony/gsm/annotations.xml b/android-sdk-annotations/android/telephony/gsm/annotations.xml
new file mode 100644
index 00000000000..a912ed620f0
--- /dev/null
+++ b/android-sdk-annotations/android/telephony/gsm/annotations.xml
@@ -0,0 +1,17 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/test/annotations.xml b/android-sdk-annotations/android/test/annotations.xml
new file mode 100644
index 00000000000..ca807da0e7a
--- /dev/null
+++ b/android-sdk-annotations/android/test/annotations.xml
@@ -0,0 +1,53 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/test/mock/annotations.xml b/android-sdk-annotations/android/test/mock/annotations.xml
new file mode 100644
index 00000000000..24c0ebe5cb2
--- /dev/null
+++ b/android-sdk-annotations/android/test/mock/annotations.xml
@@ -0,0 +1,77 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/text/annotations.xml b/android-sdk-annotations/android/text/annotations.xml
new file mode 100644
index 00000000000..143df089083
--- /dev/null
+++ b/android-sdk-annotations/android/text/annotations.xml
@@ -0,0 +1,593 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/text/format/annotations.xml b/android-sdk-annotations/android/text/format/annotations.xml
new file mode 100644
index 00000000000..80535397756
--- /dev/null
+++ b/android-sdk-annotations/android/text/format/annotations.xml
@@ -0,0 +1,104 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/text/method/annotations.xml b/android-sdk-annotations/android/text/method/annotations.xml
new file mode 100644
index 00000000000..1e07ec158ba
--- /dev/null
+++ b/android-sdk-annotations/android/text/method/annotations.xml
@@ -0,0 +1,515 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/text/style/annotations.xml b/android-sdk-annotations/android/text/style/annotations.xml
new file mode 100644
index 00000000000..d84d506a830
--- /dev/null
+++ b/android-sdk-annotations/android/text/style/annotations.xml
@@ -0,0 +1,341 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/text/util/annotations.xml b/android-sdk-annotations/android/text/util/annotations.xml
new file mode 100644
index 00000000000..a96fb684377
--- /dev/null
+++ b/android-sdk-annotations/android/text/util/annotations.xml
@@ -0,0 +1,74 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/util/annotations.xml b/android-sdk-annotations/android/util/annotations.xml
new file mode 100644
index 00000000000..6e4ff52fdc1
--- /dev/null
+++ b/android-sdk-annotations/android/util/annotations.xml
@@ -0,0 +1,230 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/view/accessibility/annotations.xml b/android-sdk-annotations/android/view/accessibility/annotations.xml
new file mode 100644
index 00000000000..cd1e6c65cf9
--- /dev/null
+++ b/android-sdk-annotations/android/view/accessibility/annotations.xml
@@ -0,0 +1,71 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/view/animation/annotations.xml b/android-sdk-annotations/android/view/animation/annotations.xml
new file mode 100644
index 00000000000..47888488fd3
--- /dev/null
+++ b/android-sdk-annotations/android/view/animation/annotations.xml
@@ -0,0 +1,116 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/view/annotations.xml b/android-sdk-annotations/android/view/annotations.xml
new file mode 100644
index 00000000000..2c577d91e44
--- /dev/null
+++ b/android-sdk-annotations/android/view/annotations.xml
@@ -0,0 +1,974 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+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 -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/view/inputmethod/annotations.xml b/android-sdk-annotations/android/view/inputmethod/annotations.xml
new file mode 100644
index 00000000000..53609ab7c39
--- /dev/null
+++ b/android-sdk-annotations/android/view/inputmethod/annotations.xml
@@ -0,0 +1,98 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/view/textservice/annotations.xml b/android-sdk-annotations/android/view/textservice/annotations.xml
new file mode 100644
index 00000000000..a4608991a52
--- /dev/null
+++ b/android-sdk-annotations/android/view/textservice/annotations.xml
@@ -0,0 +1,41 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/webkit/annotations.xml b/android-sdk-annotations/android/webkit/annotations.xml
new file mode 100644
index 00000000000..184bb9d508a
--- /dev/null
+++ b/android-sdk-annotations/android/webkit/annotations.xml
@@ -0,0 +1,194 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/android-sdk-annotations/android/widget/annotations.xml b/android-sdk-annotations/android/widget/annotations.xml
new file mode 100644
index 00000000000..cecb0d554c8
--- /dev/null
+++ b/android-sdk-annotations/android/widget/annotations.xml
@@ -0,0 +1,1838 @@
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+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 -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
diff --git a/build.xml b/build.xml
index 90421ff0b54..a0ea4b8d843 100644
--- a/build.xml
+++ b/build.xml
@@ -439,22 +439,38 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -541,11 +557,11 @@
+ depends="clean,init,prepareDist,compileGenerators,invokeGenerators,preloader,compiler,compilerSources,antTools,jdkAnnotations,androidSdkAnnotations,annotationsExt,runtime,jslib,j2kConverter"/>
+ depends="clean,init,prepareDist,preloader,compiler_quick,antTools,jdkAnnotations,androidSdkAnnotations,annotationsExt,runtime,jslib,j2kConverter"/>
emptyList(), pd.getExpectedThisObject(), receiverType);
+ boolean isStaticProperty = AsmUtil.isPropertyWithBackingFieldInOuterClass(pd)
+ && !AsmUtil.isClassObjectWithBackingFieldsInOuter(containingDeclaration);
+ JetType receiverType = !isStaticProperty ? DescriptorUtils.getReceiverParameterType(pd.getReceiverParameter()) : null;
+
+ setType(pd.getType(), Collections.emptyList(), isStaticProperty ? null : pd.getExpectedThisObject(),
+ receiverType);
initialize(new Getter(this), new Setter(this));
}
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java
index b8ac58e8cc4..2f230c791fb 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java
@@ -17,25 +17,26 @@
package org.jetbrains.jet.codegen;
import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.asm4.AnnotationVisitor;
import org.jetbrains.asm4.ClassVisitor;
import org.jetbrains.asm4.FieldVisitor;
import org.jetbrains.asm4.MethodVisitor;
-import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethods;
import org.jetbrains.jet.codegen.state.JetTypeMapper;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.annotations.Annotated;
+import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
-import org.jetbrains.jet.lang.psi.*;
+import org.jetbrains.jet.lang.psi.JetAnnotationEntry;
+import org.jetbrains.jet.lang.psi.JetClass;
+import org.jetbrains.jet.lang.psi.JetModifierList;
+import org.jetbrains.jet.lang.psi.JetModifierListOwner;
import org.jetbrains.jet.lang.resolve.BindingContext;
-import org.jetbrains.jet.lang.resolve.calls.model.DefaultValueArgument;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
-import org.jetbrains.jet.lang.resolve.calls.model.ResolvedValueArgument;
-import org.jetbrains.jet.lang.resolve.calls.model.VarargValueArgument;
-import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
-import org.jetbrains.jet.lang.resolve.name.Name;
-import org.jetbrains.jet.lang.types.JetType;
+import org.jetbrains.jet.lang.resolve.constants.*;
+import org.jetbrains.jet.lang.resolve.constants.StringValue;
+import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
@@ -84,124 +85,136 @@ public abstract class AnnotationCodegen {
AnnotationDescriptor annotationDescriptor = bindingContext.get(BindingContext.ANNOTATION, annotationEntry);
if (annotationDescriptor == null) continue; // Skipping annotations if they are not resolved. Needed for JetLightClass generation
- JetType type = annotationDescriptor.getType();
- genAnnotation(resolvedCall, type);
+ genAnnotation(annotationDescriptor);
}
}
- private void genAnnotation(
- ResolvedCall extends CallableDescriptor> resolvedCall,
- JetType type
- ) {
- ClassifierDescriptor classifierDescriptor = type.getConstructor().getDeclarationDescriptor();
+ private void genAnnotation(AnnotationDescriptor annotationDescriptor) {
+ ClassifierDescriptor classifierDescriptor = annotationDescriptor.getType().getConstructor().getDeclarationDescriptor();
RetentionPolicy rp = getRetentionPolicy(classifierDescriptor, typeMapper);
if (rp == RetentionPolicy.SOURCE) {
return;
}
- String internalName = typeMapper.mapType(type).getDescriptor();
+ String internalName = typeMapper.mapType(annotationDescriptor.getType()).getDescriptor();
AnnotationVisitor annotationVisitor = visitAnnotation(internalName, rp == RetentionPolicy.RUNTIME);
- getAnnotation(resolvedCall, annotationVisitor);
-
+ genAnnotationArguments(annotationDescriptor, annotationVisitor);
annotationVisitor.visitEnd();
}
- private void getAnnotation(ResolvedCall extends CallableDescriptor> resolvedCall, AnnotationVisitor annotationVisitor) {
- for (Map.Entry entry : resolvedCall.getValueArguments().entrySet()) {
- ResolvedValueArgument valueArgument = entry.getValue();
- if (valueArgument instanceof DefaultValueArgument) {
- continue;
- }
-
- Name keyName = entry.getKey().getName();
- genAnnotationValueArgument(annotationVisitor, valueArgument, keyName.asString());
+ private void genAnnotationArguments(AnnotationDescriptor annotationDescriptor, AnnotationVisitor annotationVisitor) {
+ for (Map.Entry> entry : annotationDescriptor.getAllValueArguments().entrySet()) {
+ ValueParameterDescriptor descriptor = entry.getKey();
+ String name = descriptor.getName().asString();
+ genAnnotationArgument(name, entry.getValue(), annotationVisitor);
}
}
- private void genAnnotationValueArgument(AnnotationVisitor annotationVisitor, ResolvedValueArgument valueArgument, String keyName) {
- List valueArguments = valueArgument.getArguments();
- if (valueArgument instanceof VarargValueArgument) {
- AnnotationVisitor visitor = annotationVisitor.visitArray(keyName);
- for (ValueArgument argument : valueArguments) {
- genAnnotationExpressionValue(visitor, null, argument.getArgumentExpression());
+ private void genAnnotationArgument(
+ @Nullable final String name,
+ @NotNull CompileTimeConstant> value,
+ @NotNull final AnnotationVisitor annotationVisitor
+ ) {
+ AnnotationArgumentVisitor argumentVisitor = new AnnotationArgumentVisitor() {
+ @Override
+ public Void visitLongValue(@NotNull LongValue value, Void data) {
+ return visitSimpleValue(value);
}
- visitor.visitEnd();
- }
- else {
- assert valueArguments.size() == 1 : "Number of arguments on " + keyName + " = " + valueArguments.size(); // todo
- JetExpression expression = valueArguments.get(0).getArgumentExpression();
- genAnnotationExpressionValue(annotationVisitor, keyName, expression);
- }
- }
- private void genAnnotationExpressionValue(AnnotationVisitor annotationVisitor, @Nullable String keyName, JetExpression expression) {
- CompileTimeConstant> compileTimeConstant =
- bindingContext.get(BindingContext.COMPILE_TIME_VALUE, expression);
+ @Override
+ public Void visitIntValue(IntValue value, Void data) {
+ return visitSimpleValue(value);
+ }
- if (compileTimeConstant != null) {
- Object value = compileTimeConstant.getValue();
- annotationVisitor.visit(keyName, value);
- return;
- }
+ @Override
+ public Void visitShortValue(ShortValue value, Void data) {
+ return visitSimpleValue(value);
+ }
- if (expression instanceof JetDotQualifiedExpression) {
- JetDotQualifiedExpression qualifiedExpression = (JetDotQualifiedExpression) expression;
- ResolvedCall extends CallableDescriptor> call =
- bindingContext.get(BindingContext.RESOLVED_CALL, qualifiedExpression.getSelectorExpression());
- if (call != null) {
- if (call.getResultingDescriptor() instanceof PropertyDescriptor) {
- PropertyDescriptor descriptor = (PropertyDescriptor) call.getResultingDescriptor();
- annotationVisitor.visitEnum(keyName, typeMapper.mapType(descriptor).getDescriptor(), descriptor.getName().asString());
- return;
+ @Override
+ public Void visitByteValue(ByteValue value, Void data) {
+ return visitSimpleValue(value);
+ }
+
+ @Override
+ public Void visitDoubleValue(DoubleValue value, Void data) {
+ return visitSimpleValue(value);
+ }
+
+ @Override
+ public Void visitFloatValue(FloatValue value, Void data) {
+ return visitSimpleValue(value);
+ }
+
+ @Override
+ public Void visitBooleanValue(BooleanValue value, Void data) {
+ return visitSimpleValue(value);
+ }
+
+ @Override
+ public Void visitCharValue(CharValue value, Void data) {
+ return visitSimpleValue(value);
+ }
+
+ @Override
+ public Void visitStringValue(StringValue value, Void data) {
+ return visitSimpleValue(value);
+ }
+
+ @Override
+ public Void visitEnumValue(EnumValue value, Void data) {
+ String propertyName = value.getValue().getName().asString();
+ annotationVisitor.visitEnum(name, typeMapper.mapType(value.getType(KotlinBuiltIns.getInstance())).getDescriptor(), propertyName);
+ return null;
+ }
+
+ @Override
+ public Void visitArrayValue(ArrayValue value, Void data) {
+ AnnotationVisitor visitor = annotationVisitor.visitArray(name);
+ for (CompileTimeConstant> argument : value.getValue()) {
+ genAnnotationArgument(null, argument, visitor);
}
+ visitor.visitEnd();
+ return null;
}
- }
- else {
- if (expression instanceof JetCallExpression) {
- JetCallExpression callExpression = (JetCallExpression) expression;
- ResolvedCall extends CallableDescriptor> call =
- bindingContext.get(BindingContext.RESOLVED_CALL, callExpression.getCalleeExpression());
- if (call != null) {
- List annotations = call.getResultingDescriptor().getOriginal().getAnnotations();
- String value = null;
- if (annotations != null) {
- for (AnnotationDescriptor annotation : annotations) {
- //noinspection ConstantConditions
- if ("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().asString())) {
- value = (String) annotation.getAllValueArguments().values().iterator().next().getValue();
- break;
- }
- }
- }
- if (IntrinsicMethods.KOTLIN_JAVA_CLASS_FUNCTION.equals(value)) {
- //noinspection ConstantConditions
- annotationVisitor.visit(keyName, typeMapper
- .mapType(call.getResultingDescriptor().getReturnType().getArguments().get(0).getType()));
- return;
- }
- else if (IntrinsicMethods.KOTLIN_ARRAYS_ARRAY.equals(value)) {
- AnnotationVisitor visitor = annotationVisitor.visitArray(keyName);
- VarargValueArgument next = (VarargValueArgument) call.getValueArguments().values().iterator().next();
- for (ValueArgument argument : next.getArguments()) {
- genAnnotationExpressionValue(visitor, null, argument.getArgumentExpression());
- }
- visitor.visitEnd();
- return;
- }
- else if (call.getResultingDescriptor() instanceof ConstructorDescriptor) {
- ConstructorDescriptor descriptor = (ConstructorDescriptor) call.getResultingDescriptor();
- AnnotationVisitor visitor = annotationVisitor.visitAnnotation(keyName, typeMapper
- .mapType(descriptor.getContainingDeclaration()).getDescriptor());
- getAnnotation(call, visitor);
- visitor.visitEnd();
- return;
- }
- }
- }
- }
- throw new IllegalStateException("Don't know how to compile annotation value");
+ @Override
+ public Void visitAnnotationValue(AnnotationValue value, Void data) {
+ String internalAnnName = typeMapper.mapType(value.getValue().getType()).getDescriptor();
+ AnnotationVisitor visitor = annotationVisitor.visitAnnotation(name, internalAnnName);
+ genAnnotationArguments(value.getValue(), visitor);
+ visitor.visitEnd();
+ return null;
+ }
+
+ @Override
+ public Void visitJavaClassValue(JavaClassValue value, Void data) {
+ annotationVisitor.visit(name, typeMapper.mapType(value.getValue()));
+ return null;
+ }
+
+ private Void visitSimpleValue(CompileTimeConstant value) {
+ annotationVisitor.visit(name, value.getValue());
+ return null;
+ }
+
+ @Override
+ public Void visitErrorValue(ErrorValue value, Void data) {
+ return visitUnsupportedValue(value);
+ }
+
+ @Override
+ public Void visitNullValue(NullValue value, Void data) {
+ return visitUnsupportedValue(value);
+ }
+
+ private Void visitUnsupportedValue(CompileTimeConstant value) {
+ throw new IllegalStateException("Don't know how to compile annotation value " + value);
+ }
+ };
+
+ value.accept(argumentVisitor, null);
}
private static RetentionPolicy getRetentionPolicy(ClassifierDescriptor descriptor, JetTypeMapper typeMapper) {
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java b/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java
index 8a818ac3f6d..ad1a395f359 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java
@@ -33,10 +33,7 @@ import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
-import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
-import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
-import org.jetbrains.jet.lang.resolve.java.JvmAbi;
-import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
+import org.jetbrains.jet.lang.resolve.java.*;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lexer.JetTokens;
@@ -47,7 +44,7 @@ import java.util.Set;
import static org.jetbrains.asm4.Opcodes.*;
import static org.jetbrains.jet.codegen.CodegenUtil.*;
-import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isClassObject;
+import static org.jetbrains.jet.lang.resolve.DescriptorUtils.*;
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.JAVA_STRING_TYPE;
public class AsmUtil {
@@ -239,15 +236,13 @@ public class AsmUtil {
return null;
}
// the following code is only for PRIVATE visibility of member
- if (isClassObject(containingDeclaration)) {
+ if (isEnumEntry(memberDescriptor)) {
return NO_FLAG_PACKAGE_PRIVATE;
}
if (memberDescriptor instanceof ConstructorDescriptor) {
ClassKind kind = ((ClassDescriptor) containingDeclaration).getKind();
if (kind == ClassKind.OBJECT) {
- //TODO: should be NO_FLAG_PACKAGE_PRIVATE
- // see http://youtrack.jetbrains.com/issue/KT-2700
- return ACC_PUBLIC;
+ return NO_FLAG_PACKAGE_PRIVATE;
}
else if (kind == ClassKind.ENUM_ENTRY) {
return NO_FLAG_PACKAGE_PRIVATE;
@@ -435,25 +430,23 @@ public class AsmUtil {
}
}
- public static Type genIncrement(Type expectedType, int myDelta, InstructionAdapter v) {
+ public static void genIncrement(Type expectedType, int myDelta, InstructionAdapter v) {
if (expectedType == Type.LONG_TYPE) {
- //noinspection UnnecessaryBoxing
v.lconst(myDelta);
}
else if (expectedType == Type.FLOAT_TYPE) {
- //noinspection UnnecessaryBoxing
v.fconst(myDelta);
}
else if (expectedType == Type.DOUBLE_TYPE) {
- //noinspection UnnecessaryBoxing
v.dconst(myDelta);
}
else {
v.iconst(myDelta);
- expectedType = Type.INT_TYPE;
+ v.add(Type.INT_TYPE);
+ StackValue.coerce(Type.INT_TYPE, expectedType, v);
+ return;
}
v.add(expectedType);
- return expectedType;
}
public static Type genNegate(Type expectedType, InstructionAdapter v) {
@@ -505,7 +498,7 @@ public class AsmUtil {
Type asmType = state.getTypeMapper().mapReturnType(type);
if (asmType.getSort() == Type.OBJECT || asmType.getSort() == Type.ARRAY) {
v.load(index, asmType);
- v.visitLdcInsn(descriptor.getName().asString());
+ v.visitLdcInsn(parameter.getName().asString());
v.invokestatic("jet/runtime/Intrinsics", "checkParameterIsNotNull", "(Ljava/lang/Object;Ljava/lang/String;)V");
}
}
@@ -555,7 +548,7 @@ public class AsmUtil {
private static boolean isDeclaredInJava(@NotNull CallableDescriptor callableDescriptor, @NotNull BindingContext context) {
CallableDescriptor descriptor = callableDescriptor;
while (true) {
- if (Boolean.TRUE.equals(context.get(BindingContext.IS_DECLARED_IN_JAVA, descriptor))) {
+ if (Boolean.TRUE.equals(context.get(JavaBindingContext.IS_DECLARED_IN_JAVA, descriptor))) {
return true;
}
CallableDescriptor original = descriptor.getOriginal();
@@ -589,10 +582,75 @@ public class AsmUtil {
}
}
+ public static boolean isPropertyWithBackingFieldInOuterClass(@NotNull PropertyDescriptor propertyDescriptor) {
+ return isPropertyWithSpecialBackingField(propertyDescriptor.getContainingDeclaration(), ClassKind.CLASS);
+ }
+
+ public static int getVisibilityForSpecialPropertyBackingField(@NotNull PropertyDescriptor propertyDescriptor, boolean isDelegate) {
+ boolean isExtensionProperty = propertyDescriptor.getReceiverParameter() != null;
+ if (isDelegate || isExtensionProperty) {
+ return ACC_PRIVATE;
+ } else {
+ return areBothAccessorDefault(propertyDescriptor) ? getVisibilityAccessFlag(descriptorForVisibility(propertyDescriptor)) : ACC_PRIVATE;
+ }
+ }
+
+ private static MemberDescriptor descriptorForVisibility(@NotNull PropertyDescriptor propertyDescriptor) {
+ if (!propertyDescriptor.isVar() ) {
+ return propertyDescriptor;
+ } else {
+ return propertyDescriptor.getSetter() != null ? propertyDescriptor.getSetter() : propertyDescriptor;
+ }
+ }
+
+ public static boolean isPropertyWithBackingFieldCopyInOuterClass(@NotNull PropertyDescriptor propertyDescriptor) {
+ boolean isExtensionProperty = propertyDescriptor.getReceiverParameter() != null;
+ return !propertyDescriptor.isVar() && !isExtensionProperty
+ && isPropertyWithSpecialBackingField(propertyDescriptor.getContainingDeclaration(), ClassKind.TRAIT)
+ && areBothAccessorDefault(propertyDescriptor)
+ && getVisibilityForSpecialPropertyBackingField(propertyDescriptor, false) == ACC_PUBLIC;
+ }
+
+ public static boolean isClassObjectWithBackingFieldsInOuter(@NotNull DeclarationDescriptor classObject) {
+ return isPropertyWithSpecialBackingField(classObject, ClassKind.CLASS);
+ }
+
+ private static boolean areBothAccessorDefault(@NotNull PropertyDescriptor propertyDescriptor) {
+ return isAccessorWithEmptyBody(propertyDescriptor.getGetter())
+ && (!propertyDescriptor.isVar() || isAccessorWithEmptyBody(propertyDescriptor.getSetter()));
+ }
+
+ private static boolean isAccessorWithEmptyBody(@Nullable PropertyAccessorDescriptor accessorDescriptor) {
+ return accessorDescriptor == null || !accessorDescriptor.hasBody();
+ }
+
+ private static boolean isPropertyWithSpecialBackingField(@NotNull DeclarationDescriptor classObject, ClassKind kind) {
+ return isClassObject(classObject) && isKindOf(classObject.getContainingDeclaration(), kind);
+ }
+
public static Type comparisonOperandType(Type left, Type right) {
if (left == Type.DOUBLE_TYPE || right == Type.DOUBLE_TYPE) return Type.DOUBLE_TYPE;
if (left == Type.FLOAT_TYPE || right == Type.FLOAT_TYPE) return Type.FLOAT_TYPE;
if (left == Type.LONG_TYPE || right == Type.LONG_TYPE) return Type.LONG_TYPE;
return Type.INT_TYPE;
}
+
+ public static void pop(@NotNull InstructionAdapter v, @NotNull Type type) {
+ if (type.getSize() == 2) {
+ v.pop2();
+ }
+ else {
+ v.pop();
+ }
+ }
+
+ public static void dup(@NotNull InstructionAdapter v, @NotNull Type type) {
+ if (type.getSize() == 2) {
+ v.dup2();
+ }
+ else {
+ v.dup();
+ }
+ }
+
}
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/CallableMethod.java b/compiler/backend/src/org/jetbrains/jet/codegen/CallableMethod.java
index e56d5ed6834..ca47be38717 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/CallableMethod.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/CallableMethod.java
@@ -105,10 +105,14 @@ public class CallableMethod implements Callable {
@NotNull GenerationState state,
@NotNull ResolvedCall resolvedCall
) {
- invoke(v);
+ invokeWithoutAssertions(v);
AsmUtil.genNotNullAssertionForMethod(v, state, resolvedCall);
}
+ public void invokeWithoutAssertions(@NotNull InstructionAdapter v) {
+ invoke(v);
+ }
+
@Nullable
public Type getGenerateCalleeType() {
return generateCalleeType;
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java
index bfbf4597349..806867b843b 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java
@@ -17,18 +17,19 @@
package org.jetbrains.jet.codegen;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.jetbrains.asm4.MethodVisitor;
import org.jetbrains.asm4.Type;
-import org.jetbrains.asm4.commons.InstructionAdapter;
-import org.jetbrains.jet.codegen.context.CodegenContext;
+import org.jetbrains.jet.codegen.context.ClassContext;
import org.jetbrains.jet.codegen.state.GenerationState;
-import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
-import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
+import org.jetbrains.jet.lang.descriptors.*;
+import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
+import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
+import org.jetbrains.jet.lang.resolve.name.Name;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -41,12 +42,20 @@ public abstract class ClassBodyCodegen extends MemberCodegen {
protected final OwnerKind kind;
protected final ClassDescriptor descriptor;
protected final ClassBuilder v;
- protected final CodegenContext context;
+ protected final ClassContext context;
- protected final List staticInitializerChunks = new ArrayList();
+ private MethodVisitor clInitMethod;
- protected ClassBodyCodegen(JetClassOrObject aClass, CodegenContext context, ClassBuilder v, GenerationState state) {
- super(state);
+ private ExpressionCodegen clInitCodegen;
+
+ protected ClassBodyCodegen(
+ @NotNull JetClassOrObject aClass,
+ @NotNull ClassContext context,
+ @NotNull ClassBuilder v,
+ @NotNull GenerationState state,
+ @Nullable MemberCodegen parentCodegen
+ ) {
+ super(state, parentCodegen);
descriptor = state.getBindingContext().get(BindingContext.CLASS, aClass);
myClass = aClass;
this.context = context;
@@ -54,7 +63,7 @@ public abstract class ClassBodyCodegen extends MemberCodegen {
this.v = v;
}
- public final void generate() {
+ public void generate() {
generateDeclaration();
generateClassBody();
@@ -73,16 +82,32 @@ public abstract class ClassBodyCodegen extends MemberCodegen {
private void generateClassBody() {
FunctionCodegen functionCodegen = new FunctionCodegen(context, v, state);
- PropertyCodegen propertyCodegen = new PropertyCodegen(context, v, functionCodegen);
+ PropertyCodegen propertyCodegen = new PropertyCodegen(context, v, functionCodegen, this);
+
+ if (kind != OwnerKind.TRAIT_IMPL) {
+ //generate nested classes first and only then generate class body. It necessary to access to nested CodegenContexts
+ for (JetDeclaration declaration : myClass.getDeclarations()) {
+ if (shouldProcessFirst(declaration)) {
+ generateDeclaration(propertyCodegen, declaration);
+ }
+ }
+ }
for (JetDeclaration declaration : myClass.getDeclarations()) {
- generateDeclaration(propertyCodegen, declaration, functionCodegen);
+ if (!shouldProcessFirst(declaration)) {
+ generateDeclaration(propertyCodegen, declaration);
+ }
}
generatePrimaryConstructorProperties(propertyCodegen, myClass);
}
- protected void generateDeclaration(PropertyCodegen propertyCodegen, JetDeclaration declaration, FunctionCodegen functionCodegen) {
+ private boolean shouldProcessFirst(JetDeclaration declaration) {
+ return false == (declaration instanceof JetProperty || declaration instanceof JetNamedFunction);
+ }
+
+
+ protected void generateDeclaration(PropertyCodegen propertyCodegen, JetDeclaration declaration) {
if (declaration instanceof JetProperty || declaration instanceof JetNamedFunction) {
genFunctionOrProperty(context, (JetTypeParameterListOwner) declaration, v);
}
@@ -125,23 +150,46 @@ public abstract class ClassBodyCodegen extends MemberCodegen {
}
private void generateStaticInitializer() {
- if (staticInitializerChunks.size() > 0) {
- MethodVisitor mv = v.newMethod(null, ACC_PUBLIC | ACC_STATIC, "", "()V", null, null);
+ if (clInitMethod != null) {
+ createOrGetClInitMethod();
+
if (state.getClassBuilderMode() == ClassBuilderMode.FULL) {
- mv.visitCode();
+ ExpressionCodegen codegen = createOrGetClInitCodegen();
- InstructionAdapter v = new InstructionAdapter(mv);
-
- for (CodeChunk chunk : staticInitializerChunks) {
- chunk.generate(v);
- }
-
- mv.visitInsn(RETURN);
- FunctionCodegen.endVisit(v, "static initializer", myClass);
+ createOrGetClInitMethod().visitInsn(RETURN);
+ FunctionCodegen.endVisit(codegen.v, "static initializer", myClass);
}
}
}
+ @Nullable
+ protected MethodVisitor createOrGetClInitMethod() {
+ if (clInitMethod == null) {
+ clInitMethod = v.newMethod(null, ACC_STATIC, "", "()V", null, null);
+ }
+ return clInitMethod;
+ }
+
+ @Nullable
+ protected ExpressionCodegen createOrGetClInitCodegen() {
+ assert state.getClassBuilderMode() == ClassBuilderMode.FULL;
+ if (state.getClassBuilderMode() == ClassBuilderMode.FULL) {
+ if (clInitCodegen == null) {
+ MethodVisitor method = createOrGetClInitMethod();
+ method.visitCode();
+ SimpleFunctionDescriptorImpl clInit =
+ new SimpleFunctionDescriptorImpl(descriptor, Collections.emptyList(),
+ Name.special(""),
+ CallableMemberDescriptor.Kind.SYNTHESIZED);
+ clInit.initialize(null, null, Collections.emptyList(),
+ Collections.emptyList(), null, null, Visibilities.PRIVATE, false);
+
+ clInitCodegen = new ExpressionCodegen(method, new FrameMap(), Type.VOID_TYPE, context.intoFunction(clInit), state);
+ }
+ }
+ return clInitCodegen;
+ }
+
private void generateRemoveInIterator() {
// generates stub 'remove' function for subclasses of Iterator to be compatible with java.util.Iterator
if (DescriptorUtils.isIteratorWithoutRemoveImpl(descriptor)) {
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/CodeChunk.java b/compiler/backend/src/org/jetbrains/jet/codegen/CodeChunk.java
index 9aa1cb2ca30..293a3fdbfe6 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/CodeChunk.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/CodeChunk.java
@@ -16,8 +16,6 @@
package org.jetbrains.jet.codegen;
-import org.jetbrains.asm4.commons.InstructionAdapter;
-
public interface CodeChunk {
- void generate(InstructionAdapter v);
+ void generate(ExpressionCodegen codegen);
}
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java
index f0cfb552f19..740e2574d9e 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java
@@ -17,6 +17,8 @@
package org.jetbrains.jet.codegen;
import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.psi.PsiFile;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.Stack;
import org.jetbrains.annotations.NotNull;
@@ -27,6 +29,7 @@ import org.jetbrains.jet.codegen.context.NamespaceContext;
import org.jetbrains.jet.codegen.signature.BothSignatureWriter;
import org.jetbrains.jet.codegen.signature.JvmMethodParameterKind;
import org.jetbrains.jet.codegen.signature.JvmMethodSignature;
+import org.jetbrains.jet.codegen.state.JetTypeMapper;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
@@ -263,14 +266,33 @@ public class CodegenUtil {
return false;
}
- public static boolean couldUseDirectAccessToProperty(PropertyDescriptor propertyDescriptor, boolean forGetter, boolean isInsideClass, boolean isDelegated) {
+ public static boolean couldUseDirectAccessToProperty(@NotNull PropertyDescriptor propertyDescriptor, boolean forGetter, boolean isInsideClass, boolean isDelegated) {
PropertyAccessorDescriptor accessorDescriptor = forGetter ? propertyDescriptor.getGetter() : propertyDescriptor.getSetter();
boolean isExtensionProperty = propertyDescriptor.getReceiverParameter() != null;
+ boolean specialTypeProperty = isDelegated ||
+ isExtensionProperty ||
+ DescriptorUtils.isClassObject(propertyDescriptor.getContainingDeclaration()) ||
+ JetTypeMapper.isAccessor(propertyDescriptor);
return isInsideClass &&
- !isDelegated &&
- !isExtensionProperty &&
+ !specialTypeProperty &&
(accessorDescriptor == null ||
accessorDescriptor.isDefault() &&
(!DescriptorUtils.isExternallyAccessible(propertyDescriptor) || accessorDescriptor.getModality() == Modality.FINAL));
}
+
+ @NotNull
+ public static ImplementationBodyCodegen getParentBodyCodegen(@Nullable MemberCodegen classBodyCodegen) {
+ assert classBodyCodegen != null &&
+ classBodyCodegen
+ .getParentCodegen() instanceof ImplementationBodyCodegen : "Class object should have appropriate parent BodyCodegen";
+
+ return ((ImplementationBodyCodegen) classBodyCodegen.getParentCodegen());
+ }
+
+ static int getPathHashCode(@NotNull PsiFile file) {
+ // Conversion to system-dependent name seems to be unnecessary, but it's hard to check now:
+ // it was introduced when fixing KT-2839, which appeared again (KT-3639).
+ // If you try to remove it, run tests on Windows.
+ return FileUtil.toSystemDependentName(file.getVirtualFile().getPath()).hashCode();
+ }
}
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
index 46b869544f4..f1b8ab91304 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
@@ -22,6 +22,7 @@ import com.intellij.openapi.editor.Document;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.psi.PsiElement;
import com.intellij.psi.tree.IElementType;
+import com.intellij.util.ArrayUtil;
import com.intellij.util.Function;
import com.intellij.util.containers.Stack;
import org.jetbrains.annotations.NotNull;
@@ -50,10 +51,8 @@ import org.jetbrains.jet.lang.resolve.calls.model.*;
import org.jetbrains.jet.lang.resolve.calls.util.CallMaker;
import org.jetbrains.jet.lang.resolve.calls.util.ExpressionAsFunctionDescriptor;
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
-import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
-import org.jetbrains.jet.lang.resolve.java.JvmClassName;
-import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
-import org.jetbrains.jet.lang.resolve.java.sam.SingleAbstractMethodUtils;
+import org.jetbrains.jet.lang.resolve.java.*;
+import org.jetbrains.jet.lang.resolve.java.descriptor.ClassDescriptorFromJvmBytecode;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.receivers.*;
import org.jetbrains.jet.lang.types.JetType;
@@ -87,6 +86,7 @@ public class ExpressionCodegen extends JetVisitor implem
private int myLastLineNumber = -1;
final InstructionAdapter v;
+ final MethodVisitor methodVisitor;
final FrameMap myFrameMap;
final JetTypeMapper typeMapper;
@@ -94,7 +94,7 @@ public class ExpressionCodegen extends JetVisitor implem
private final Type returnType;
private final BindingContext bindingContext;
- final CodegenContext context;
+ final MethodContext context;
private final CodegenStatementVisitor statementVisitor;
private final Stack blockStackElements = new Stack();
@@ -121,8 +121,8 @@ public class ExpressionCodegen extends JetVisitor implem
//noinspection SuspiciousMethodCalls
CalculatedClosure closure = bindingContext.get(CLOSURE, classDescriptor);
- CodegenContext objectContext = context.intoAnonymousClass(classDescriptor, this);
- ImplementationBodyCodegen implementationBodyCodegen = new ImplementationBodyCodegen(objectDeclaration, objectContext, classBuilder, state);
+ ClassContext objectContext = context.intoAnonymousClass(classDescriptor, this);
+ ImplementationBodyCodegen implementationBodyCodegen = new ImplementationBodyCodegen(objectDeclaration, objectContext, classBuilder, state, null);
implementationBodyCodegen.generate();
@@ -154,29 +154,33 @@ public class ExpressionCodegen extends JetVisitor implem
public ExpressionCodegen(
- MethodVisitor v,
- FrameMap myMap,
- Type returnType,
- CodegenContext context,
- GenerationState state
+ @NotNull MethodVisitor v,
+ @NotNull FrameMap myMap,
+ @NotNull Type returnType,
+ @NotNull MethodContext context,
+ @NotNull GenerationState state
) {
this.myFrameMap = myMap;
this.typeMapper = state.getTypeMapper();
this.returnType = returnType;
this.state = state;
- this.v = new InstructionAdapter(v) {
- @Override
- public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
- super.visitLocalVariable(name, desc, signature, start, end,
- index);
- localVariableNames.add(name);
- }
- };
+ this.methodVisitor = v;
+ this.v = createInstructionAdapter(methodVisitor);
this.bindingContext = state.getBindingContext();
this.context = context;
this.statementVisitor = new CodegenStatementVisitor(this);
}
+ protected InstructionAdapter createInstructionAdapter(MethodVisitor mv) {
+ return new InstructionAdapter(methodVisitor) {
+ @Override
+ public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
+ super.visitLocalVariable(name, desc, signature, start, end, index);
+ localVariableNames.add(name);
+ }
+ };
+ }
+
public GenerationState getState() {
return state;
}
@@ -187,7 +191,9 @@ public class ExpressionCodegen extends JetVisitor implem
}
if (provided instanceof CallableDescriptor) {
- provided = ((CallableDescriptor) provided).getReceiverParameter().getType().getConstructor().getDeclarationDescriptor();
+ ReceiverParameterDescriptor receiverParameter = ((CallableDescriptor) provided).getReceiverParameter();
+ assert receiverParameter != null : receiverParameter;
+ provided = receiverParameter.getType().getConstructor().getDeclarationDescriptor();
}
assert provided instanceof ClassDescriptor;
@@ -221,14 +227,19 @@ public class ExpressionCodegen extends JetVisitor implem
if (!(selector instanceof JetBlockExpression)) {
markLineNumber(selector);
}
- if (selector instanceof JetExpression) {
- JetExpression expression = (JetExpression) selector;
- CompileTimeConstant> constant = bindingContext.get(BindingContext.COMPILE_TIME_VALUE, expression);
- if (constant != null) {
- return StackValue.constant(constant.getValue(), expressionType(expression));
- }
- }
try {
+ if (selector instanceof JetExpression) {
+ JetExpression expression = (JetExpression) selector;
+ CompileTimeConstant> constant = bindingContext.get(BindingContext.COMPILE_TIME_VALUE, expression);
+ if (constant != null) {
+ return StackValue.constant(constant.getValue(), expressionType(expression));
+ }
+ ClassDescriptorFromJvmBytecode samInterface = bindingContext.get(CodegenBinding.SAM_VALUE, expression);
+ if (samInterface != null) {
+ return genSamInterfaceValue(expression, samInterface, visitor);
+ }
+ }
+
return selector.accept(visitor, receiver);
}
catch (ProcessCanceledException e) {
@@ -275,9 +286,9 @@ public class ExpressionCodegen extends JetVisitor implem
ClassBuilder classBuilder = state.getFactory().newVisitor(className.getInternalName(), declaration.getContainingFile()
);
- CodegenContext objectContext = context.intoAnonymousClass(descriptor, this);
+ ClassContext objectContext = context.intoAnonymousClass(descriptor, this);
- new ImplementationBodyCodegen(declaration, objectContext, classBuilder, state).generate();
+ new ImplementationBodyCodegen(declaration, objectContext, classBuilder, state, null).generate();
return StackValue.none();
}
@@ -310,8 +321,7 @@ public class ExpressionCodegen extends JetVisitor implem
return labelTarget;
}
assert descriptor instanceof ClassDescriptor : "Don't know how to generate super-call to not a class";
- ClassDescriptor target = getParentContextSubclassOf((ClassDescriptor) descriptor, context).getThisDescriptor();
- return target;
+ return getParentContextSubclassOf((ClassDescriptor) descriptor, context).getThisDescriptor();
}
@NotNull
@@ -459,12 +469,11 @@ public class ExpressionCodegen extends JetVisitor implem
RangeCodegenUtil.BinaryCall binaryCall = RangeCodegenUtil.getRangeAsBinaryCall(forExpression);
if (binaryCall != null) {
ResolvedCall extends CallableDescriptor> resolvedCall = bindingContext.get(RESOLVED_CALL, binaryCall.op);
- assert resolvedCall != null;
-
- CallableDescriptor rangeTo = resolvedCall.getResultingDescriptor();
- if (RangeCodegenUtil.isOptimizableRangeTo(rangeTo)) {
- generateForLoop(new ForInRangeLiteralLoopGenerator(forExpression, binaryCall));
- return StackValue.none();
+ if (resolvedCall != null) {
+ if (RangeCodegenUtil.isOptimizableRangeTo(resolvedCall.getResultingDescriptor())) {
+ generateForLoop(new ForInRangeLiteralLoopGenerator(forExpression, binaryCall));
+ return StackValue.none();
+ }
}
}
@@ -502,16 +511,17 @@ public class ExpressionCodegen extends JetVisitor implem
Label continueLabel = new Label();
generator.beforeLoop();
+ generator.checkEmptyLoop(loopExit);
v.mark(loopEntry);
- generator.conditionAndJump(loopExit);
+ generator.checkPreCondition(loopExit);
generator.beforeBody();
blockStackElements.push(new LoopBlockStackElement(loopExit, continueLabel, targetLabel(generator.forExpression)));
generator.body();
blockStackElements.pop();
v.mark(continueLabel);
- generator.afterBody();
+ generator.afterBody(loopExit);
v.goTo(loopEntry);
@@ -576,7 +586,9 @@ public class ExpressionCodegen extends JetVisitor implem
}
}
- public abstract void conditionAndJump(@NotNull Label loopExit);
+ public abstract void checkEmptyLoop(@NotNull Label loopExit);
+
+ public abstract void checkPreCondition(@NotNull Label loopExit);
public void beforeBody() {
v.mark(bodyStart);
@@ -621,7 +633,7 @@ public class ExpressionCodegen extends JetVisitor implem
protected abstract void assignToLoopParameter();
- protected abstract void increment();
+ protected abstract void increment(@NotNull Label loopExit);
public void body() {
gen(forExpression.getBody(), Type.VOID_TYPE);
@@ -642,8 +654,8 @@ public class ExpressionCodegen extends JetVisitor implem
return varIndex;
}
- public void afterBody() {
- increment();
+ public void afterBody(@NotNull Label loopExit) {
+ increment(loopExit);
v.mark(bodyEnd);
}
@@ -706,7 +718,11 @@ public class ExpressionCodegen extends JetVisitor implem
}
@Override
- public void conditionAndJump(@NotNull Label loopExit) {
+ public void checkEmptyLoop(@NotNull Label loopExit) {
+ }
+
+ @Override
+ public void checkPreCondition(@NotNull Label loopExit) {
// tmp.hasNext()
JetExpression loopRange = forExpression.getLoopRange();
@@ -734,7 +750,7 @@ public class ExpressionCodegen extends JetVisitor implem
}
@Override
- protected void increment() {
+ protected void increment(@NotNull Label loopExit) {
}
}
@@ -771,7 +787,11 @@ public class ExpressionCodegen extends JetVisitor implem
}
@Override
- public void conditionAndJump(@NotNull Label loopExit) {
+ public void checkEmptyLoop(@NotNull Label loopExit) {
+ }
+
+ @Override
+ public void checkPreCondition(@NotNull Label loopExit) {
v.load(indexVar, Type.INT_TYPE);
v.load(arrayVar, OBJECT_TYPE);
v.arraylength();
@@ -796,51 +816,33 @@ public class ExpressionCodegen extends JetVisitor implem
}
@Override
- protected void increment() {
+ protected void increment(@NotNull Label loopExit) {
v.iinc(indexVar, 1);
}
}
- private abstract class AbstractForInRangeLoopGenerator extends AbstractForLoopGenerator {
+ private abstract class AbstractForInProgressionOrRangeLoopGenerator extends AbstractForLoopGenerator {
protected int endVar;
- private AbstractForInRangeLoopGenerator(@NotNull JetForExpression forExpression) {
+ // For integer progressions instead of comparing loopParameterVar with endVar at the beginning of an iteration we check whether
+ // loopParameterVar == finalVar at the end of the iteration (and also if there should be any iterations at all, before the loop)
+ protected final boolean isIntegerProgression;
+
+ private AbstractForInProgressionOrRangeLoopGenerator(@NotNull JetForExpression forExpression) {
super(forExpression);
- }
- @Override
- public void beforeLoop() {
- super.beforeLoop();
-
- endVar = createLoopTempVariable(asmElementType);
- storeRangeStartAndEnd();
- }
-
- protected abstract void storeRangeStartAndEnd();
-
- @Override
- public void conditionAndJump(@NotNull Label loopExit) {
- v.load(loopParameterVar, asmElementType);
- v.load(endVar, asmElementType);
-
- int sort = asmElementType.getSort();
- switch (sort) {
+ switch (asmElementType.getSort()) {
case Type.INT:
- case Type.CHAR:
case Type.BYTE:
case Type.SHORT:
- v.ificmpgt(loopExit);
- break;
-
+ case Type.CHAR:
case Type.LONG:
- v.lcmp();
- v.ifgt(loopExit);
+ isIntegerProgression = true;
break;
- case Type.FLOAT:
case Type.DOUBLE:
- v.cmpg(asmElementType);
- v.ifgt(loopExit);
+ case Type.FLOAT:
+ isIntegerProgression = false;
break;
default:
@@ -848,48 +850,96 @@ public class ExpressionCodegen extends JetVisitor implem
}
}
+ @Override
+ public void beforeLoop() {
+ super.beforeLoop();
+
+ endVar = createLoopTempVariable(asmElementType);
+ }
+
+ // Index of the local variable holding the actual last value of the loop parameter.
+ // For ranges it equals end, for progressions it's a function of start, end and increment
+ protected abstract int getFinalVar();
+
+ protected void checkPostCondition(@NotNull Label loopExit) {
+ int finalVar = getFinalVar();
+ assert isIntegerProgression && finalVar != -1 :
+ "Post-condition should be checked only in case of integer progressions, finalVar = " + finalVar;
+
+ v.load(loopParameterVar, asmElementType);
+ v.load(finalVar, asmElementType);
+ if (asmElementType.getSort() == Type.LONG) {
+ v.lcmp();
+ v.ifeq(loopExit);
+ }
+ else {
+ v.ificmpeq(loopExit);
+ }
+ }
+ }
+
+ private abstract class AbstractForInRangeLoopGenerator extends AbstractForInProgressionOrRangeLoopGenerator {
+ private AbstractForInRangeLoopGenerator(@NotNull JetForExpression forExpression) {
+ super(forExpression);
+ }
+
+ @Override
+ public void beforeLoop() {
+ super.beforeLoop();
+
+ storeRangeStartAndEnd();
+ }
+
+ protected abstract void storeRangeStartAndEnd();
+
+ @Override
+ protected int getFinalVar() {
+ return endVar;
+ }
+
+ @Override
+ public void checkPreCondition(@NotNull Label loopExit) {
+ if (isIntegerProgression) return;
+
+ v.load(loopParameterVar, asmElementType);
+ v.load(endVar, asmElementType);
+
+ v.cmpg(asmElementType);
+ v.ifgt(loopExit);
+ }
+
+ @Override
+ public void checkEmptyLoop(@NotNull Label loopExit) {
+ if (!isIntegerProgression) return;
+
+ v.load(loopParameterVar, asmElementType);
+ v.load(endVar, asmElementType);
+ if (asmElementType.getSort() == Type.LONG) {
+ v.lcmp();
+ v.ifgt(loopExit);
+ }
+ else {
+ v.ificmpgt(loopExit);
+ }
+ }
+
@Override
protected void assignToLoopParameter() {
}
@Override
- protected void increment() {
- int sort = asmElementType.getSort();
- switch (sort) {
- case Type.INT:
- case Type.CHAR:
- case Type.BYTE:
- case Type.SHORT:
- v.iinc(loopParameterVar, 1);
- if (sort != Type.INT) {
- v.load(loopParameterVar, Type.INT_TYPE);
- StackValue.coerce(Type.INT_TYPE, asmElementType, v);
- v.store(loopParameterVar, asmElementType);
- }
- break;
+ protected void increment(@NotNull Label loopExit) {
+ if (isIntegerProgression) {
+ checkPostCondition(loopExit);
+ }
- case Type.LONG:
- v.load(loopParameterVar, asmElementType);
- v.lconst(1);
- v.add(asmElementType);
- v.store(loopParameterVar, asmElementType);
- break;
-
- case Type.FLOAT:
- case Type.DOUBLE:
- v.load(loopParameterVar, asmElementType);
- if (sort == Type.DOUBLE) {
- v.dconst(1.0);
- }
- else {
- v.fconst(1.0f);
- }
- v.add(asmElementType);
- v.store(loopParameterVar, asmElementType);
- break;
-
- default:
- throw new IllegalStateException("Unexpected range element type: " + asmElementType);
+ if (asmElementType == Type.INT_TYPE) {
+ v.iinc(loopParameterVar, 1);
+ }
+ else {
+ v.load(loopParameterVar, asmElementType);
+ genIncrement(asmElementType, 1, v);
+ v.store(loopParameterVar, asmElementType);
}
}
}
@@ -933,20 +983,25 @@ public class ExpressionCodegen extends JetVisitor implem
}
}
- private class ForInProgressionExpressionLoopGenerator extends AbstractForLoopGenerator {
- private int endVar;
+ private class ForInProgressionExpressionLoopGenerator extends AbstractForInProgressionOrRangeLoopGenerator {
private int incrementVar;
private Type incrementType;
+ private int finalVar;
+
private ForInProgressionExpressionLoopGenerator(@NotNull JetForExpression forExpression) {
super(forExpression);
}
+ @Override
+ protected int getFinalVar() {
+ return finalVar;
+ }
+
@Override
public void beforeLoop() {
super.beforeLoop();
- endVar = createLoopTempVariable(asmElementType);
incrementVar = createLoopTempVariable(asmElementType);
JetType loopRangeType = bindingContext.get(EXPRESSION_TYPE, forExpression.getLoopRange());
@@ -964,87 +1019,99 @@ public class ExpressionCodegen extends JetVisitor implem
generateRangeOrProgressionProperty(asmLoopRangeType, "getStart", asmElementType, loopParameterVar);
generateRangeOrProgressionProperty(asmLoopRangeType, "getEnd", asmElementType, endVar);
generateRangeOrProgressionProperty(asmLoopRangeType, "getIncrement", incrementType, incrementVar);
+
+ storeFinalVar();
+ }
+
+ private void storeFinalVar() {
+ if (!isIntegerProgression) {
+ finalVar = -1;
+ return;
+ }
+
+ v.load(loopParameterVar, asmElementType);
+ v.load(endVar, asmElementType);
+ v.load(incrementVar, incrementType);
+
+ Type methodParamType = asmElementType.getSort() == Type.LONG ? Type.LONG_TYPE : Type.INT_TYPE;
+ v.invokestatic("jet/runtime/ProgressionUtil", "getProgressionFinalElement",
+ Type.getMethodDescriptor(methodParamType, methodParamType, methodParamType, methodParamType));
+
+ finalVar = createLoopTempVariable(asmElementType);
+ v.store(finalVar, asmElementType);
}
@Override
- public void conditionAndJump(@NotNull Label loopExit) {
+ public void checkPreCondition(@NotNull Label loopExit) {
+ if (isIntegerProgression) return;
+
v.load(loopParameterVar, asmElementType);
- v.load(incrementVar, asmElementType);
+ v.load(endVar, asmElementType);
+ v.load(incrementVar, incrementType);
Label negativeIncrement = new Label();
Label afterIf = new Label();
- int sort = asmElementType.getSort();
- switch (sort) {
- case Type.INT:
- case Type.CHAR:
- case Type.BYTE:
- case Type.SHORT:
- v.ifle(negativeIncrement); // if increment < 0, jump
-
- // increment > 0
- v.load(endVar, asmElementType);
- v.ificmpgt(loopExit);
- v.goTo(afterIf);
-
- // increment < 0
- v.visitLabel(negativeIncrement);
- v.load(endVar, asmElementType);
- v.ificmplt(loopExit);
- v.visitLabel(afterIf);
-
- break;
-
- case Type.LONG:
- v.lconst(0L);
- v.lcmp();
- v.ifle(negativeIncrement); // if increment < 0, jump
-
- // increment > 0
- v.load(endVar, asmElementType);
- v.lcmp();
- v.ifgt(loopExit);
- v.goTo(afterIf);
-
- // increment < 0
- v.visitLabel(negativeIncrement);
- v.load(endVar, asmElementType);
- v.lcmp();
- v.iflt(loopExit);
- v.visitLabel(afterIf);
-
- break;
-
- case Type.DOUBLE:
- case Type.FLOAT:
- if (sort == Type.DOUBLE) {
- v.dconst(0.0);
- }
- else {
- v.fconst(0.0f);
- }
- v.cmpl(incrementType);
- v.ifle(negativeIncrement); // if increment < 0, jump
-
- // increment > 0
- v.load(endVar, asmElementType);
- v.cmpg(asmElementType); // if loop parameter is NaN, exit from loop, as well
- v.ifgt(loopExit);
- v.goTo(afterIf);
-
- // increment < 0
- v.visitLabel(negativeIncrement);
- v.load(endVar, asmElementType);
- v.cmpl(asmElementType); // if loop parameter is NaN, exit from loop, as well
- v.iflt(loopExit);
- v.visitLabel(afterIf);
-
- break;
-
- default:
- throw new IllegalStateException("Unexpected range element type: " + asmElementType);
+ if (incrementType.getSort() == Type.DOUBLE) {
+ v.dconst(0.0);
}
+ else {
+ v.fconst(0.0f);
+ }
+ v.cmpl(incrementType);
+ v.ifle(negativeIncrement); // if increment < 0, jump
+ // increment > 0
+ v.cmpg(asmElementType); // if loop parameter is NaN, exit from loop, as well
+ v.ifgt(loopExit);
+ v.goTo(afterIf);
+
+ // increment < 0
+ v.mark(negativeIncrement);
+ v.cmpl(asmElementType); // if loop parameter is NaN, exit from loop, as well
+ v.iflt(loopExit);
+ v.mark(afterIf);
+ }
+
+ @Override
+ public void checkEmptyLoop(@NotNull Label loopExit) {
+ if (!isIntegerProgression) return;
+
+ v.load(loopParameterVar, asmElementType);
+ v.load(endVar, asmElementType);
+ v.load(incrementVar, incrementType);
+
+ Label negativeIncrement = new Label();
+ Label afterIf = new Label();
+
+ if (asmElementType.getSort() == Type.LONG) {
+ v.lconst(0L);
+ v.lcmp();
+ v.ifle(negativeIncrement); // if increment < 0, jump
+
+ // increment > 0
+ v.lcmp();
+ v.ifgt(loopExit);
+ v.goTo(afterIf);
+
+ // increment < 0
+ v.mark(negativeIncrement);
+ v.lcmp();
+ v.iflt(loopExit);
+ v.mark(afterIf);
+ }
+ else {
+ v.ifle(negativeIncrement); // if increment < 0, jump
+
+ // increment > 0
+ v.ificmpgt(loopExit);
+ v.goTo(afterIf);
+
+ // increment < 0
+ v.mark(negativeIncrement);
+ v.ificmplt(loopExit);
+ v.mark(afterIf);
+ }
}
@Override
@@ -1052,14 +1119,16 @@ public class ExpressionCodegen extends JetVisitor implem
}
@Override
- protected void increment() {
+ protected void increment(@NotNull Label loopExit) {
+ if (isIntegerProgression) {
+ checkPostCondition(loopExit);
+ }
v.load(loopParameterVar, asmElementType);
v.load(incrementVar, asmElementType);
v.add(asmElementType);
- int sort = asmElementType.getSort();
- if (sort == Type.CHAR || sort == Type.BYTE || sort == Type.SHORT) {
+ if (asmElementType == Type.BYTE_TYPE || asmElementType == Type.SHORT_TYPE || asmElementType == Type.CHAR_TYPE) {
StackValue.coerce(Type.INT_TYPE, asmElementType, v);
}
@@ -1067,6 +1136,7 @@ public class ExpressionCodegen extends JetVisitor implem
}
}
+
@Override
public StackValue visitBreakExpression(JetBreakExpression expression, StackValue receiver) {
JetSimpleNameExpression labelElement = expression.getTargetLabel();
@@ -1540,7 +1610,6 @@ public class ExpressionCodegen extends JetVisitor implem
assert descriptor != null;
- DeclarationDescriptor container = descriptor.getContainingDeclaration();
if (descriptor instanceof VariableDescriptor) {
VariableDescriptor variableDescriptor = (VariableDescriptor) descriptor;
@@ -1562,8 +1631,8 @@ public class ExpressionCodegen extends JetVisitor implem
expression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER && contextKind() != OwnerKind.TRAIT_IMPL;
JetExpression r = getReceiverForSelector(expression);
boolean isSuper = r instanceof JetSuperExpression;
- propertyDescriptor = accessablePropertyDescriptor(context, propertyDescriptor);
- StackValue.Property iValue =
+ propertyDescriptor = accessiblePropertyDescriptor(propertyDescriptor);
+ StackValue iValue =
intermediateValueForProperty(propertyDescriptor, directToField, isSuper ? (JetSuperExpression) r : null);
if (directToField) {
receiver = StackValue.receiverWithoutReceiverArgument(receiver);
@@ -1672,29 +1741,26 @@ public class ExpressionCodegen extends JetVisitor implem
}
@NotNull
- public StackValue.Property intermediateValueForProperty(
- PropertyDescriptor propertyDescriptor,
+ public StackValue intermediateValueForProperty(
+ @NotNull PropertyDescriptor propertyDescriptor,
boolean forceField,
@Nullable JetSuperExpression superExpression
) {
- return intermediateValueForProperty(propertyDescriptor, forceField, superExpression, state, context, false);
+ return intermediateValueForProperty(propertyDescriptor, forceField, superExpression, MethodKind.GENERAL);
}
- @NotNull
- public static StackValue.Property intermediateValueForProperty(
- PropertyDescriptor propertyDescriptor,
+ public StackValue.StackValueWithSimpleReceiver intermediateValueForProperty(
+ @NotNull PropertyDescriptor propertyDescriptor,
boolean forceField,
@Nullable JetSuperExpression superExpression,
- @NotNull GenerationState state,
- @NotNull CodegenContext context,
- @NotNull boolean forceSpecialFlag
+ @NotNull MethodKind methodKind
) {
JetTypeMapper typeMapper = state.getTypeMapper();
DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration();
- assert containingDeclaration != null;
- boolean isStatic = containingDeclaration instanceof NamespaceDescriptor;
+ boolean isBackingFieldInAnotherClass = AsmUtil.isPropertyWithBackingFieldInOuterClass(propertyDescriptor);
+ boolean isStatic = containingDeclaration instanceof NamespaceDescriptor || isBackingFieldInAnotherClass;
boolean isSuper = superExpression != null;
boolean isInsideClass = isCallInsideSameClassAsDeclared(propertyDescriptor, context);
boolean isInsideModule = isCallInsideSameModuleAsDeclared(propertyDescriptor, context);
@@ -1702,11 +1768,25 @@ public class ExpressionCodegen extends JetVisitor implem
JetType delegateType = getPropertyDelegateType(propertyDescriptor, state.getBindingContext());
boolean isDelegatedProperty = delegateType != null;
+
CallableMethod callableGetter = null;
CallableMethod callableSetter = null;
- if (!forceField) {
- //noinspection ConstantConditions
+ boolean skipPropertyAccessors = forceField && !isBackingFieldInAnotherClass;
+
+ CodegenContext backingFieldContext = context.getParentContext();
+
+ if (isBackingFieldInAnotherClass && forceField) {
+ //delegate call to classObject owner : OWNER
+ backingFieldContext = context.findParentContextWithDescriptor(containingDeclaration.getContainingDeclaration());
+ int flags = AsmUtil.getVisibilityForSpecialPropertyBackingField(propertyDescriptor, isDelegatedProperty);
+ skipPropertyAccessors = (flags & ACC_PRIVATE) == 0 || methodKind == MethodKind.SYNTHETIC_ACCESSOR || methodKind == MethodKind.INITIALIZER;
+ if (!skipPropertyAccessors) {
+ propertyDescriptor = (PropertyDescriptor) backingFieldContext.getAccessor(propertyDescriptor);
+ }
+ }
+
+ if (!skipPropertyAccessors) {
if (couldUseDirectAccessToProperty(propertyDescriptor, true, isInsideClass, isDelegatedProperty)) {
callableGetter = null;
}
@@ -1720,20 +1800,26 @@ public class ExpressionCodegen extends JetVisitor implem
}
}
- propertyDescriptor = accessablePropertyDescriptor(context, propertyDescriptor);
+ propertyDescriptor = accessiblePropertyDescriptor(propertyDescriptor);
- if (propertyDescriptor.getGetter() != null) {
- callableGetter = typeMapper.mapToCallableMethod(propertyDescriptor.getGetter(), isSuper || forceSpecialFlag, isInsideClass, isInsideModule, OwnerKind.IMPLEMENTATION);
+ PropertyGetterDescriptor getter = propertyDescriptor.getGetter();
+ if (getter != null) {
+ callableGetter = typeMapper.mapToCallableMethod(
+ getter, isSuper || MethodKind.SYNTHETIC_ACCESSOR == methodKind, isInsideClass, isInsideModule,
+ OwnerKind.IMPLEMENTATION);
}
}
if (propertyDescriptor.isVar()) {
- if (propertyDescriptor.getSetter() != null) {
+ PropertySetterDescriptor setter = propertyDescriptor.getSetter();
+ if (setter != null) {
if (couldUseDirectAccessToProperty(propertyDescriptor, false, isInsideClass, isDelegatedProperty)) {
callableSetter = null;
}
else {
- callableSetter = typeMapper.mapToCallableMethod(propertyDescriptor.getSetter(), isSuper || forceSpecialFlag, isInsideClass, isInsideModule, OwnerKind.IMPLEMENTATION);
+ callableSetter = typeMapper.mapToCallableMethod(
+ setter, isSuper || MethodKind.SYNTHETIC_ACCESSOR == methodKind, isInsideClass, isInsideModule,
+ OwnerKind.IMPLEMENTATION);
}
}
}
@@ -1744,20 +1830,25 @@ public class ExpressionCodegen extends JetVisitor implem
propertyDescriptor = unwrapFakeOverride(propertyDescriptor);
if (callableMethod == null) {
- owner = typeMapper.getOwner(propertyDescriptor, context.getContextKind(), isInsideModule);
+ owner = typeMapper.getOwner(isBackingFieldInAnotherClass ? propertyDescriptor.getContainingDeclaration() : propertyDescriptor,
+ context.getContextKind(), isInsideModule);
}
else {
owner = callableMethod.getOwner();
}
- if (isDelegatedProperty && forceField) {
- return StackValue.property(propertyDescriptor, owner, typeMapper.mapType(delegateType),
- isStatic, true, callableGetter, callableSetter, state);
- }
- else {
- return StackValue.property(propertyDescriptor, owner, typeMapper.mapType(propertyDescriptor.getOriginal().getType()),
- isStatic, false, callableGetter, callableSetter, state);
+ String name;
+ if (propertyDescriptor.getContainingDeclaration() == backingFieldContext.getContextDescriptor()) {
+ assert backingFieldContext instanceof FieldOwnerContext : "Actual context is " + backingFieldContext + " but should be instance of FieldOwnerContext" ;
+ name = ((FieldOwnerContext) backingFieldContext).getFieldName(propertyDescriptor, isDelegatedProperty);
+ } else {
+ name = JvmAbi.getDefaultPropertyName(propertyDescriptor.getName(), isDelegatedProperty, propertyDescriptor.getReceiverParameter() != null);
}
+
+ return StackValue.property(propertyDescriptor, owner,
+ typeMapper.mapType(isDelegatedProperty && forceField ? delegateType : propertyDescriptor.getOriginal().getType()),
+ isStatic, name, callableGetter, callableSetter, state);
+
}
@Override
@@ -1776,7 +1867,7 @@ public class ExpressionCodegen extends JetVisitor implem
throw new UnsupportedOperationException("unknown type of callee descriptor: " + funDescriptor);
}
- funDescriptor = accessableFunctionDescriptor((FunctionDescriptor) funDescriptor);
+ funDescriptor = accessibleFunctionDescriptor((FunctionDescriptor) funDescriptor);
if (funDescriptor instanceof ConstructorDescriptor) {
return generateNewCall(expression, resolvedCall, receiver);
@@ -1790,42 +1881,21 @@ public class ExpressionCodegen extends JetVisitor implem
}
if (funDescriptor instanceof SimpleFunctionDescriptor) {
- ClassDescriptor samInterface = bindingContext.get(
- BindingContext.SAM_CONSTRUCTOR_TO_INTERFACE, ((SimpleFunctionDescriptor) funDescriptor).getOriginal());
+ ClassDescriptorFromJvmBytecode samInterface = bindingContext.get(
+ JavaBindingContext.SAM_CONSTRUCTOR_TO_INTERFACE, ((SimpleFunctionDescriptor) funDescriptor).getOriginal());
if (samInterface != null) {
- return invokeSamConstructor(expression, resolvedCall, (SimpleFunctionDescriptor) funDescriptor, samInterface);
+ return invokeSamConstructor(expression, resolvedCall, samInterface);
}
}
return invokeFunction(call, receiver, resolvedCall);
}
- @Nullable
- private SimpleFunctionDescriptor getOriginalIfSamAdapter(@NotNull CallableDescriptor fun) {
- if (!(fun instanceof SimpleFunctionDescriptor)) {
- return null;
- }
- SimpleFunctionDescriptor original = ((SimpleFunctionDescriptor) fun).getOriginal();
- if (original.getKind() == CallableMemberDescriptor.Kind.SYNTHESIZED) {
- return bindingContext.get(SAM_ADAPTER_FUNCTION_TO_ORIGINAL, original);
- }
- if (original.getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
- for (FunctionDescriptor overridden : original.getOverriddenDescriptors()) {
- SimpleFunctionDescriptor originalIfSamAdapter = getOriginalIfSamAdapter(overridden);
- if (originalIfSamAdapter != null) {
- return originalIfSamAdapter;
- }
- }
- }
- return null;
- }
-
private StackValue invokeSamConstructor(
JetCallExpression expression,
ResolvedCall extends CallableDescriptor> resolvedCall,
- SimpleFunctionDescriptor funDescriptor,
- ClassDescriptor samInterface
+ ClassDescriptorFromJvmBytecode samInterface
) {
ResolvedValueArgument argument = resolvedCall.getValueArgumentsByIndex().get(0);
if (!(argument instanceof ExpressionValueArgument)) {
@@ -1835,66 +1905,60 @@ public class ExpressionCodegen extends JetVisitor implem
ValueArgument valueArgument = ((ExpressionValueArgument) argument).getValueArgument();
assert valueArgument != null : "getValueArgument() is null for " + expression.getText();
JetExpression argumentExpression = valueArgument.getArgumentExpression();
+ assert argumentExpression != null : "getArgumentExpression() is null for " + expression.getText();
- if (argumentExpression instanceof JetFunctionLiteralExpression) {
- return genClosure(((JetFunctionLiteralExpression) argumentExpression).getFunctionLiteral(), samInterface);
+ return genSamInterfaceValue(argumentExpression, samInterface, this);
+ }
+
+ private StackValue genSamInterfaceValue(
+ @NotNull JetExpression expression,
+ @NotNull ClassDescriptorFromJvmBytecode samInterface,
+ @NotNull JetVisitor visitor
+ ) {
+ if (expression instanceof JetFunctionLiteralExpression) {
+ return genClosure(((JetFunctionLiteralExpression) expression).getFunctionLiteral(), samInterface);
}
else {
- JvmClassName className = new SamWrapperCodegen(state, samInterface).genWrapper(expression, argumentExpression);
+ JvmClassName className =
+ state.getSamWrapperClasses().getSamWrapperClass(samInterface, (JetFile) expression.getContainingFile());
v.anew(className.getAsmType());
v.dup();
- JetType functionType = funDescriptor.getValueParameters().get(0).getType();
- gen(argumentExpression, typeMapper.mapType(functionType));
+ Type functionType = typeMapper.mapType(samInterface.getFunctionTypeForSamInterface());
+ expression.accept(visitor, StackValue.none()).put(functionType, v);
- v.invokespecial(className.getInternalName(), "",
- Type.getMethodDescriptor(Type.VOID_TYPE, typeMapper.mapType(functionType)));
+ Label ifNonNull = new Label();
+ Label afterAll = new Label();
+
+ v.dup();
+ v.ifnonnull(ifNonNull);
+
+ // if null: pop function value and wrapper objects, put null
+ v.pop();
+ v.pop2();
+ v.aconst(null);
+ v.goTo(afterAll);
+
+ v.mark(ifNonNull);
+ v.invokespecial(className.getInternalName(), "", Type.getMethodDescriptor(Type.VOID_TYPE, functionType));
+
+ v.mark(afterAll);
return StackValue.onStack(className.getAsmType());
}
}
- private static PropertyDescriptor accessablePropertyDescriptor(CodegenContext context, PropertyDescriptor propertyDescriptor) {
- PropertySetterDescriptor setter = propertyDescriptor.getSetter();
- PropertyGetterDescriptor getter = propertyDescriptor.getGetter();
-
- int flag = getVisibilityAccessFlag(propertyDescriptor) |
- (getter == null ? 0 : getVisibilityAccessFlag(getter)) |
- (setter == null ? 0 : getVisibilityAccessFlag(setter));
-
- if ((flag & ACC_PRIVATE) == 0) {
- return propertyDescriptor;
- }
-
- return (PropertyDescriptor) accessibleDescriptor(context, propertyDescriptor);
+ @NotNull
+ private PropertyDescriptor accessiblePropertyDescriptor(PropertyDescriptor propertyDescriptor) {
+ return context.accessiblePropertyDescriptor(propertyDescriptor);
}
- private FunctionDescriptor accessableFunctionDescriptor(FunctionDescriptor fd) {
- int flag = getVisibilityAccessFlag(fd);
- if ((flag & ACC_PRIVATE) == 0) {
- return fd;
- }
-
- return (FunctionDescriptor) accessibleDescriptor(context, fd);
- }
-
- private static MemberDescriptor accessibleDescriptor(CodegenContext context, DeclarationDescriptor descriptor) {
- if (context.getClassOrNamespaceDescriptor() != descriptor.getContainingDeclaration()) {
- DeclarationDescriptor enclosed = descriptor.getContainingDeclaration();
- if (context.hasThisDescriptor() && enclosed != context.getThisDescriptor()) {
- CodegenContext c = context;
- while (c.getContextDescriptor() != enclosed) {
- c = c.getParentContext();
- if (c == null) {
- return (MemberDescriptor) descriptor;
- }
- }
- return (MemberDescriptor) c.getAccessor(descriptor);
- }
- }
- return (MemberDescriptor) descriptor;
+ @NotNull
+ protected FunctionDescriptor accessibleFunctionDescriptor(FunctionDescriptor fd) {
+ return context.accessibleFunctionDescriptor(fd);
}
+ @NotNull
public StackValue invokeFunction(
Call call,
StackValue receiver,
@@ -1913,7 +1977,7 @@ public class ExpressionCodegen extends JetVisitor implem
}
}
- fd = accessableFunctionDescriptor(fd);
+ fd = accessibleFunctionDescriptor(fd);
Callable callable = resolveToCallable(fd, superCall);
if (callable instanceof CallableMethod) {
@@ -1943,7 +2007,7 @@ public class ExpressionCodegen extends JetVisitor implem
}
@Nullable
- private static JetSuperExpression getSuperCallExpression(Call call) {
+ private static JetSuperExpression getSuperCallExpression(@NotNull Call call) {
ReceiverValue explicitReceiver = call.getExplicitReceiver();
if (explicitReceiver instanceof ExpressionReceiver) {
JetExpression receiverExpression = ((ExpressionReceiver) explicitReceiver).getExpression();
@@ -1954,7 +2018,7 @@ public class ExpressionCodegen extends JetVisitor implem
return null;
}
- private static boolean isSuperCall(Call call) {
+ private static boolean isSuperCall(@NotNull Call call) {
return getSuperCallExpression(call) != null;
}
@@ -1963,8 +2027,7 @@ public class ExpressionCodegen extends JetVisitor implem
private static CodegenContext getParentContextSubclassOf(ClassDescriptor descriptor, CodegenContext context) {
CodegenContext c = context;
while (true) {
- if ((c instanceof ClassContext || c instanceof AnonymousClassContext) &&
- DescriptorUtils.isSubclass(c.getThisDescriptor(), descriptor)) {
+ if (c instanceof ClassContext && DescriptorUtils.isSubclass(c.getThisDescriptor(), descriptor)) {
return c;
}
c = c.getParentContext();
@@ -1972,6 +2035,7 @@ public class ExpressionCodegen extends JetVisitor implem
}
}
+ @NotNull
private StackValue returnValueAsStackValue(FunctionDescriptor fd, Type callReturnType) {
if (callReturnType != Type.VOID_TYPE) {
JetType type = fd.getReturnType();
@@ -1999,7 +2063,8 @@ public class ExpressionCodegen extends JetVisitor implem
return typeMapper.mapToFunctionInvokeCallableMethod(createInvoke(fd));
}
else {
- SimpleFunctionDescriptor originalOfSamAdapter = getOriginalIfSamAdapter(fd);
+ SimpleFunctionDescriptor originalOfSamAdapter = (SimpleFunctionDescriptor) SamCodegenUtil
+ .getOriginalIfSamAdapter(bindingContext, fd);
return typeMapper.mapToCallableMethod(originalOfSamAdapter != null ? originalOfSamAdapter : fd, superCall,
isCallInsideSameClassAsDeclared(fd, context),
isCallInsideSameModuleAsDeclared(fd, context),
@@ -2233,31 +2298,19 @@ public class ExpressionCodegen extends JetVisitor implem
int mask = 0;
- SimpleFunctionDescriptor originalOfSamAdapter = getOriginalIfSamAdapter(fd);
-
for (ValueParameterDescriptor valueParameter : fd.getValueParameters()) {
ResolvedValueArgument resolvedValueArgument = valueArguments.get(valueParameter.getIndex());
+ Type parameterType = valueParameterTypes.get(valueParameter.getIndex());
if (resolvedValueArgument instanceof ExpressionValueArgument) {
ValueArgument valueArgument = ((ExpressionValueArgument) resolvedValueArgument).getValueArgument();
assert valueArgument != null;
JetExpression argumentExpression = valueArgument.getArgumentExpression();
assert argumentExpression != null : valueArgument.asElement().getText();
- if (originalOfSamAdapter != null) {
- JetType samAdapterType = originalOfSamAdapter.getValueParameters().get(valueParameter.getIndex()).getType();
- if (SingleAbstractMethodUtils.isSamType(samAdapterType)) {
- ClassDescriptor samInterface = (ClassDescriptor) samAdapterType.getConstructor().getDeclarationDescriptor();
-
- // TODO support not literals
- genClosure(((JetFunctionLiteralExpression) argumentExpression).getFunctionLiteral(), samInterface);
- continue;
- }
- }
- gen(argumentExpression, valueParameterTypes.get(valueParameter.getIndex()));
+ gen(argumentExpression, parameterType);
}
else if (resolvedValueArgument instanceof DefaultValueArgument) {
- Type type = valueParameterTypes.get(valueParameter.getIndex());
- pushDefaultValueOnStack(type, v);
+ pushDefaultValueOnStack(parameterType, v);
mask |= (1 << valueParameter.getIndex());
}
else if (resolvedValueArgument instanceof VarargValueArgument) {
@@ -2347,8 +2400,7 @@ public class ExpressionCodegen extends JetVisitor implem
@NotNull
public Type expressionType(JetExpression expr) {
- JetType type = bindingContext.get(BindingContext.EXPRESSION_TYPE, expr);
- return asmTypeOrVoid(type);
+ return typeMapper.expressionType(expr);
}
public int indexOfLocal(JetReferenceExpression lhs) {
@@ -2376,8 +2428,9 @@ public class ExpressionCodegen extends JetVisitor implem
JvmClassName closureSuperClass = JvmClassName.byType(typeMapper.mapType(kFunctionImpl));
ClosureCodegen closureCodegen = new ClosureCodegen(state, expression, functionDescriptor, null, closureSuperClass, context, this,
- new FunctionGenerationStrategy.CodegenBased(state, functionDescriptor) {
+ new FunctionGenerationStrategy.CodegenBased(state, functionDescriptor) {
+ @NotNull
@Override
public ExpressionCodegen initializeExpressionCodegen(
JvmMethodSignature signature, MethodContext context, MethodVisitor mv,
@@ -2392,9 +2445,9 @@ public class ExpressionCodegen extends JetVisitor implem
}
@Override
- public void doGenerateBody(ExpressionCodegen codegen, JvmMethodSignature signature) {
+ public void doGenerateBody(@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature) {
/*
- Here we need to put the arguments from our locals to the stack and invoke the referenced method. Since invokation
+ Here we need to put the arguments from our locals to the stack and invoke the referenced method. Since invocation
of methods is highly dependent on expressions, we create a fake call expression. Then we create a new instance of
ExpressionCodegen and, in order for it to generate code correctly, we save to its 'tempVariables' field every
argument of our fake expression, pointing it to the corresponding index in our locals. This way generation of
@@ -2437,7 +2490,9 @@ public class ExpressionCodegen extends JetVisitor implem
Type returnType = codegen.returnType;
if (referencedFunction instanceof ConstructorDescriptor) {
if (returnType.getSort() == Type.ARRAY) {
- codegen.generateNewArray(fakeExpression, referencedFunction.getReturnType());
+ JetType returnJetType = referencedFunction.getReturnType();
+ assert returnJetType != null;
+ codegen.generateNewArray(fakeExpression, returnJetType);
result = StackValue.onStack(returnType);
}
else {
@@ -2587,6 +2642,7 @@ public class ExpressionCodegen extends JetVisitor implem
}
else {
DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference());
+ assert op instanceof FunctionDescriptor : String.valueOf(op);
Callable callable = resolveToCallable((FunctionDescriptor) op, false);
if (callable instanceof IntrinsicMethod) {
IntrinsicMethod intrinsic = (IntrinsicMethod) callable;
@@ -2803,13 +2859,16 @@ public class ExpressionCodegen extends JetVisitor implem
private StackValue generateAssignmentExpression(JetBinaryExpression expression) {
StackValue stackValue = gen(expression.getLeft());
- gen(expression.getRight(), stackValue.type);
+ JetExpression right = expression.getRight();
+ assert right != null : expression.getText();
+ gen(right, stackValue.type);
stackValue.store(stackValue.type, v);
return StackValue.none();
}
private StackValue generateAugmentedAssignment(JetBinaryExpression expression) {
DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference());
+ assert op instanceof FunctionDescriptor : String.valueOf(op);
Callable callable = resolveToCallable((FunctionDescriptor) op, false);
JetExpression lhs = expression.getLeft();
@@ -2915,6 +2974,7 @@ public class ExpressionCodegen extends JetVisitor implem
}
DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference());
+ assert op instanceof FunctionDescriptor : String.valueOf(op);
Callable callable = resolveToCallable((FunctionDescriptor) op, false);
if (callable instanceof IntrinsicMethod) {
IntrinsicMethod intrinsic = (IntrinsicMethod) callable;
@@ -2978,94 +3038,92 @@ public class ExpressionCodegen extends JetVisitor implem
v.mark(ok);
return StackValue.onStack(base.type);
}
+
DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference());
- if (op instanceof FunctionDescriptor) {
- Type asmType = expressionType(expression);
- DeclarationDescriptor cls = op.getContainingDeclaration();
- if (op.getName().asString().equals("inc") || op.getName().asString().equals("dec")) {
- if (isPrimitiveNumberClassDescriptor(cls)) {
- receiver.put(receiver.type, v);
- JetExpression operand = expression.getBaseExpression();
- if (operand instanceof JetReferenceExpression) {
- int index = indexOfLocal((JetReferenceExpression) operand);
- if (index >= 0 && isIntPrimitive(asmType)) {
- int increment = op.getName().asString().equals("inc") ? 1 : -1;
- return StackValue.postIncrement(index, increment);
- }
- }
- gen(operand, asmType); // old value
- generateIncrement(op, asmType, operand, receiver); // increment in-place
- return StackValue.onStack(asmType); // old value
- }
- else {
- ResolvedCall extends CallableDescriptor> resolvedCall =
- bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
- assert resolvedCall != null;
+ if (!(op instanceof FunctionDescriptor)) {
+ throw new UnsupportedOperationException("Don't know how to generate this postfix expression: " + op);
+ }
- Callable callable = resolveToCallable((FunctionDescriptor) op, false);
+ Type asmType = expressionType(expression);
+ DeclarationDescriptor cls = op.getContainingDeclaration();
- StackValue value = gen(expression.getBaseExpression());
- value.dupReceiver(v);
+ int increment;
+ if (op.getName().asString().equals("inc")) {
+ increment = 1;
+ }
+ else if (op.getName().asString().equals("dec")) {
+ increment = -1;
+ }
+ else {
+ throw new UnsupportedOperationException("Unsupported postfix operation: " + op);
+ }
- Type type = expressionType(expression.getBaseExpression());
- value.put(type, v);
-
- switch (value.receiverSize()) {
- case 0:
- if (type.getSize() == 2) {
- v.dup2();
- }
- else {
- v.dup();
- }
- break;
-
- case 1:
- if (type.getSize() == 2) {
- v.dup2X1();
- }
- else {
- v.dupX1();
- }
- break;
-
- case 2:
- if (type.getSize() == 2) {
- v.dup2X2();
- }
- else {
- v.dupX2();
- }
- break;
-
- case -1:
- throw new UnsupportedOperationException();
- }
-
- CallableMethod callableMethod = (CallableMethod) callable;
- callableMethod.invokeWithNotNullAssertion(v, state, resolvedCall);
-
- value.store(callableMethod.getReturnType(), v);
- return StackValue.onStack(type);
+ if (isPrimitiveNumberClassDescriptor(cls)) {
+ receiver.put(receiver.type, v);
+ JetExpression operand = expression.getBaseExpression();
+ if (operand instanceof JetReferenceExpression && asmType == Type.INT_TYPE) {
+ int index = indexOfLocal((JetReferenceExpression) operand);
+ if (index >= 0) {
+ return StackValue.postIncrement(index, increment);
}
}
+ gen(operand, asmType); // old value
+ generateIncrement(increment, asmType, operand, receiver); // increment in-place
+ return StackValue.onStack(asmType); // old value
+ }
+ else {
+ ResolvedCall extends CallableDescriptor> resolvedCall =
+ bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
+ assert resolvedCall != null;
+
+ Callable callable = resolveToCallable((FunctionDescriptor) op, false);
+
+ StackValue value = gen(expression.getBaseExpression());
+ value.dupReceiver(v);
+
+ Type type = expressionType(expression.getBaseExpression());
+ value.put(type, v);
+
+ switch (value.receiverSize()) {
+ case 0:
+ dup(v, type);
+ break;
+
+ case 1:
+ if (type.getSize() == 2) {
+ v.dup2X1();
+ }
+ else {
+ v.dupX1();
+ }
+ break;
+
+ case 2:
+ if (type.getSize() == 2) {
+ v.dup2X2();
+ }
+ else {
+ v.dupX2();
+ }
+ break;
+
+ case -1:
+ throw new UnsupportedOperationException();
+ }
+
+ CallableMethod callableMethod = (CallableMethod) callable;
+ callableMethod.invokeWithNotNullAssertion(v, state, resolvedCall);
+
+ value.store(callableMethod.getReturnType(), v);
+ return StackValue.onStack(type);
}
- throw new UnsupportedOperationException("Don't know how to generate this postfix expression");
}
- private void generateIncrement(DeclarationDescriptor op, Type asmType, JetExpression operand, StackValue receiver) {
- int increment = op.getName().asString().equals("inc") ? 1 : -1;
- if (operand instanceof JetReferenceExpression) {
- int index = indexOfLocal((JetReferenceExpression) operand);
- if (index >= 0 && isIntPrimitive(asmType)) {
- v.iinc(index, increment);
- return;
- }
- }
+ private void generateIncrement(int increment, Type asmType, JetExpression operand, StackValue receiver) {
StackValue value = genQualified(receiver, operand);
value.dupReceiver(v);
value.put(asmType, v);
- asmType = genIncrement(asmType, increment, v);
+ genIncrement(asmType, increment, v);
value.store(asmType, v);
}
@@ -3206,7 +3264,9 @@ public class ExpressionCodegen extends JetVisitor implem
//See StackValue.receiver for more info
pushClosureOnStack(closure, resolvedCall.getThisObject().exists() || resolvedCall.getReceiverArgument().exists());
- CallableMethod method = typeMapper.mapToCallableMethod(constructorDescriptor);
+ ConstructorDescriptor originalOfSamAdapter = (ConstructorDescriptor) SamCodegenUtil
+ .getOriginalIfSamAdapter(bindingContext, constructorDescriptor);
+ CallableMethod method = typeMapper.mapToCallableMethod(originalOfSamAdapter == null ? constructorDescriptor : originalOfSamAdapter);
invokeMethodWithArguments(method, resolvedCall, null, StackValue.none());
return StackValue.onStack(type);
@@ -3305,60 +3365,33 @@ public class ExpressionCodegen extends JetVisitor implem
}
}
else {
- CallableMethod accessor = typeMapper.mapToCallableMethod(
- operationDescriptor,
- false,
- isCallInsideSameClassAsDeclared(operationDescriptor, context),
- isCallInsideSameModuleAsDeclared(operationDescriptor, context),
- OwnerKind.IMPLEMENTATION);
-
- boolean isGetter = accessor.getSignature().getAsmMethod().getName().equals("get");
-
ResolvedCall resolvedSetCall = bindingContext.get(BindingContext.INDEXED_LVALUE_SET, expression);
ResolvedCall resolvedGetCall = bindingContext.get(BindingContext.INDEXED_LVALUE_GET, expression);
- FunctionDescriptor setterDescriptor = resolvedSetCall == null ? null : resolvedSetCall.getResultingDescriptor();
- FunctionDescriptor getterDescriptor = resolvedGetCall == null ? null : resolvedGetCall.getResultingDescriptor();
+ boolean isGetter = "get".equals(operationDescriptor.getName().asString());
- Type asmType;
- Type[] argumentTypes = accessor.getSignature().getAsmMethod().getArgumentTypes();
- int index = 0;
- if (isGetter) {
- assert getterDescriptor != null;
- Callable callable = resolveToCallable(getterDescriptor, false);
- if (callable instanceof CallableMethod) {
- genThisAndReceiverFromResolvedCall(receiver, resolvedGetCall, (CallableMethod) callable);
- }
- else {
- gen(array, asmType(((ClassDescriptor) getterDescriptor.getContainingDeclaration()).getDefaultType()));
- }
+ ResolvedCall resolvedCall = isGetter ? resolvedGetCall : resolvedSetCall;
+ assert resolvedCall != null : "couldn't find resolved call: " + expression.getText();
- if (getterDescriptor.getReceiverParameter() != null) {
- index++;
- }
- asmType = accessor.getSignature().getAsmMethod().getReturnType();
+ Callable callable = resolveToCallable(operationDescriptor, false);
+ if (callable instanceof CallableMethod) {
+ genThisAndReceiverFromResolvedCall(receiver, resolvedCall, (CallableMethod) callable);
}
else {
- assert resolvedSetCall != null;
- Callable callable = resolveToCallable(resolvedSetCall.getResultingDescriptor(), false);
- if (callable instanceof CallableMethod) {
- genThisAndReceiverFromResolvedCall(receiver, resolvedSetCall, (CallableMethod) callable);
- }
- else {
- gen(array, arrayType);
- }
-
- if (setterDescriptor.getReceiverParameter() != null) {
- index++;
- }
- asmType = argumentTypes[argumentTypes.length - 1];
+ gen(array, arrayType); // intrinsic method
}
+ int index = operationDescriptor.getReceiverParameter() != null ? 1 : 0;
+
+ Method asmMethod = resolveToCallableMethod(operationDescriptor, false, context).getSignature().getAsmMethod();
+ Type[] argumentTypes = asmMethod.getArgumentTypes();
for (JetExpression jetExpression : expression.getIndexExpressions()) {
gen(jetExpression, argumentTypes[index]);
index++;
}
- return StackValue.collectionElement(asmType, resolvedGetCall, resolvedSetCall, this, state);
+
+ Type elementType = isGetter ? asmMethod.getReturnType() : ArrayUtil.getLastElement(argumentTypes);
+ return StackValue.collectionElement(elementType, resolvedGetCall, resolvedSetCall, this, state);
}
}
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java
index ccbff63900f..d0e6525faeb 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java
@@ -37,6 +37,7 @@ import org.jetbrains.jet.codegen.signature.kotlin.JetMethodAnnotationWriter;
import org.jetbrains.jet.codegen.signature.kotlin.JetValueParameterAnnotationWriter;
import org.jetbrains.jet.codegen.state.GenerationState;
import org.jetbrains.jet.codegen.state.GenerationStateAware;
+import org.jetbrains.jet.codegen.state.JetTypeMapper;
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.JetNamedFunction;
@@ -132,6 +133,8 @@ public class FunctionCodegen extends GenerationStateAware {
endVisit(mv, null, origin);
generateBridgeIfNeeded(owner, state, v, jvmSignature.getAsmMethod(), functionDescriptor);
+
+ methodContext.recordSyntheticAccessorIfNeeded(functionDescriptor, typeMapper);
}
@Nullable
@@ -180,7 +183,9 @@ public class FunctionCodegen extends GenerationStateAware {
labelsForSharedVars.putAll(createSharedVarsForParameters(mv, functionDescriptor, frameMap));
- genNotNullAssertionsForParameters(new InstructionAdapter(mv), state, functionDescriptor, frameMap);
+ if (!JetTypeMapper.isAccessor(functionDescriptor)) {
+ genNotNullAssertionsForParameters(new InstructionAdapter(mv), state, functionDescriptor, frameMap);
+ }
strategy.generateBody(mv, signature, context);
@@ -812,7 +817,8 @@ public class FunctionCodegen extends GenerationStateAware {
StackValue.onStack(overriddenMethod.getReturnType()).put(delegateMethod.getReturnType(), iv);
iv.areturn(delegateMethod.getReturnType());
- endVisit(mv, "delegate method", descriptorToDeclaration(bindingContext, functionDescriptor));
+ endVisit(mv, "Delegate method " + functionDescriptor + " to " + jvmOverriddenMethodSignature,
+ descriptorToDeclaration(bindingContext, functionDescriptor.getContainingDeclaration()));
generateBridgeIfNeeded(owner, state, v, jvmDelegateMethodSignature.getAsmMethod(), functionDescriptor);
}
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionGenerationStrategy.java b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionGenerationStrategy.java
index 6a7f7426e47..b9cbcb900c0 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionGenerationStrategy.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionGenerationStrategy.java
@@ -19,7 +19,6 @@ package org.jetbrains.jet.codegen;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.asm4.MethodVisitor;
import org.jetbrains.asm4.Type;
-import org.jetbrains.jet.codegen.context.CodegenContext;
import org.jetbrains.jet.codegen.context.MethodContext;
import org.jetbrains.jet.codegen.signature.JvmMethodSignature;
import org.jetbrains.jet.codegen.state.GenerationState;
@@ -30,7 +29,7 @@ import org.jetbrains.jet.lang.psi.JetDeclarationWithBody;
import java.util.ArrayList;
import java.util.Collection;
-public abstract class FunctionGenerationStrategy {
+public abstract class FunctionGenerationStrategy {
private final Collection localVariableNames = new ArrayList();
@@ -78,14 +77,14 @@ public abstract class FunctionGenerationStrategy {
}
@Override
- public void doGenerateBody(ExpressionCodegen codegen, JvmMethodSignature signature) {
+ public void doGenerateBody(@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature) {
codegen.returnExpression(declaration.getBodyExpression());
}
}
- public abstract static class CodegenBased extends FunctionGenerationStrategy {
+ public abstract static class CodegenBased extends FunctionGenerationStrategy {
- private final GenerationState state;
+ protected final GenerationState state;
protected final T callableDescriptor;
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java
index 785d3a0913e..ec0ef763764 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java
@@ -20,6 +20,8 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.util.Pair;
+import com.intellij.psi.PsiElement;
+import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.asm4.AnnotationVisitor;
@@ -31,7 +33,7 @@ import org.jetbrains.asm4.commons.Method;
import org.jetbrains.jet.codegen.binding.CalculatedClosure;
import org.jetbrains.jet.codegen.binding.CodegenBinding;
import org.jetbrains.jet.codegen.binding.MutableClosure;
-import org.jetbrains.jet.codegen.context.CodegenContext;
+import org.jetbrains.jet.codegen.context.ClassContext;
import org.jetbrains.jet.codegen.context.ConstructorContext;
import org.jetbrains.jet.codegen.context.MethodContext;
import org.jetbrains.jet.codegen.signature.*;
@@ -66,7 +68,9 @@ import static org.jetbrains.jet.codegen.AsmUtil.*;
import static org.jetbrains.jet.codegen.CodegenUtil.*;
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.callableDescriptorToDeclaration;
+import static org.jetbrains.jet.lang.resolve.BindingContextUtils.descriptorToDeclaration;
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.*;
+import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isKindOf;
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.JAVA_STRING_TYPE;
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.OBJECT_TYPE;
@@ -79,13 +83,21 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private final Type classAsmType;
private final FunctionCodegen functionCodegen;
- private final PropertyCodegen propertyCodegen;
+ private final PropertyCodegen propertyCodegen;
- public ImplementationBodyCodegen(JetClassOrObject aClass, CodegenContext context, ClassBuilder v, GenerationState state) {
- super(aClass, context, v, state);
+ private List classObjectPropertiesToCopy;
+
+ public ImplementationBodyCodegen(
+ @NotNull JetClassOrObject aClass,
+ @NotNull ClassContext context,
+ @NotNull ClassBuilder v,
+ @NotNull GenerationState state,
+ @Nullable MemberCodegen parentCodegen
+ ) {
+ super(aClass, context, v, state, parentCodegen);
this.classAsmType = typeMapper.mapType(descriptor.getDefaultType(), JetTypeMapperMode.IMPL);
this.functionCodegen = new FunctionCodegen(context, v, state);
- this.propertyCodegen = new PropertyCodegen(context, v, this.functionCodegen);
+ this.propertyCodegen = new PropertyCodegen(context, v, this.functionCodegen, this);
}
@Override
@@ -97,7 +109,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
boolean isAbstract = false;
boolean isInterface = false;
boolean isFinal = false;
- boolean isStatic = false;
+ boolean isStatic;
boolean isAnnotation = false;
boolean isEnum = false;
@@ -185,7 +197,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
signature.getName(),
signature.getJavaGenericSignature(),
signature.getSuperclassName(),
- interfaces.toArray(new String[interfaces.size()])
+ ArrayUtil.toStringArray(interfaces)
);
v.visitSource(myClass.getContainingFile().getName(), null);
@@ -429,6 +441,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
protected void generateSyntheticParts() {
generateFieldForSingleton();
+ generateClassObjectBackingFieldCopies();
+
try {
generatePrimaryConstructor();
}
@@ -446,7 +460,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
generateSyntheticAccessors();
- generateEnumMethods();
+ generateEnumMethodsAndConstInitializers();
generateFunctionsForDataClasses();
@@ -458,8 +472,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
for (JetParameter parameter : getPrimaryConstructorParameters()) {
if (parameter.getValOrVarNode() == null) continue;
- PropertyDescriptor propertyDescriptor = state.getBindingContext().get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter);
- assert propertyDescriptor != null;
+ PropertyDescriptor propertyDescriptor = DescriptorUtils.getPropertyDescriptor(parameter, bindingContext);
result.add(propertyDescriptor);
}
@@ -760,12 +773,23 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
: "Trying to create function with default arguments for function that isn't presented in code for class without data annotation";
PropertyDescriptor propertyDescriptor = codegen.getBindingContext().get(
BindingContext.VALUE_PARAMETER_AS_PROPERTY, descriptor);
- assert propertyDescriptor != null : "Trying to generate default value for parameter of copy function that doesn't correspond to any property";
+ assert propertyDescriptor != null
+ : "Trying to generate default value for parameter of copy function that doesn't correspond to any property";
codegen.v.load(0, thisDescriptorType);
Type propertyType = codegen.typeMapper.mapType(propertyDescriptor.getType());
codegen.intermediateValueForProperty(propertyDescriptor, false, null).put(propertyType, codegen.v);
}
});
+}
+
+ private void generateEnumMethodsAndConstInitializers() {
+ if (!myEnumConstants.isEmpty()) {
+ generateEnumMethods();
+
+ if (state.getClassBuilderMode() == ClassBuilderMode.FULL) {
+ initializeEnumConstants(createOrGetClInitCodegen());
+ }
+ }
}
private void generateEnumMethods() {
@@ -802,8 +826,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
}
- private void generateSyntheticAccessors() {
- for (Map.Entry entry : context.getAccessors().entrySet()) {
+ protected void generateSyntheticAccessors() {
+ Map accessors = context.getAccessors();
+ for (Map.Entry entry : accessors.entrySet()) {
generateSyntheticAccessor(entry);
}
}
@@ -811,60 +836,34 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private void generateSyntheticAccessor(Map.Entry entry) {
if (entry.getValue() instanceof FunctionDescriptor) {
FunctionDescriptor bridge = (FunctionDescriptor) entry.getValue();
- FunctionDescriptor original = (FunctionDescriptor) entry.getKey();
+ final FunctionDescriptor original = (FunctionDescriptor) entry.getKey();
+ functionCodegen.generateMethod(null, typeMapper.mapSignature(bridge), false, bridge,
+ new FunctionGenerationStrategy.CodegenBased(state, bridge) {
+ @Override
+ public void doGenerateBody(@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature) {
+ generateMethodCallTo(original, codegen.v);
- Method method = typeMapper.mapSignature(bridge).getAsmMethod();
- boolean isConstructor = original instanceof ConstructorDescriptor;
- Method originalMethod = isConstructor ?
- typeMapper.mapConstructorSignature((ConstructorDescriptor) original).getAsmMethod() :
- typeMapper.mapSignature(original).getAsmMethod();
- Type[] argTypes = method.getArgumentTypes();
-
- String owner = typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION, isCallInsideSameModuleAsDeclared(original, context)).getInternalName();
- MethodVisitor mv = v.newMethod(null, ACC_SYNTHETIC | ACC_STATIC, bridge.getName().asString(),
- method.getDescriptor(), null, null);
- if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
- genStubCode(mv);
- }
- else if (state.getClassBuilderMode() == ClassBuilderMode.FULL) {
- mv.visitCode();
-
- InstructionAdapter iv = new InstructionAdapter(mv);
-
- if (isConstructor) {
- iv.anew(method.getReturnType());
- iv.dup();
- }
- else {
- // todo: note that for now we never have access bridges for namespace methods, if at some point we do...
- iv.load(0, OBJECT_TYPE);
- }
-
- for (int i = isConstructor ? 0 : 1, reg = isConstructor ? 0 : 1; i < argTypes.length; i++) {
- Type argType = argTypes[i];
- iv.load(reg, argType);
- //noinspection AssignmentToForLoopParameter
- reg += argType.getSize();
- }
- iv.invokespecial(owner, originalMethod.getName(), originalMethod.getDescriptor());
-
- iv.areturn(method.getReturnType());
- FunctionCodegen.endVisit(iv, "accessor", null);
- }
+ codegen.v.areturn(signature.getAsmMethod().getReturnType());
+ }
+ });
}
else if (entry.getValue() instanceof PropertyDescriptor) {
- PropertyDescriptor bridge = (PropertyDescriptor) entry.getValue();
+ final PropertyDescriptor bridge = (PropertyDescriptor) entry.getValue();
final PropertyDescriptor original = (PropertyDescriptor) entry.getKey();
- final StackValue.Property property = ExpressionCodegen.intermediateValueForProperty(original, false, null, state, context, true);
+
PropertyGetterDescriptor getter = bridge.getGetter();
assert getter != null;
functionCodegen.generateMethod(null, typeMapper.mapGetterSignature(bridge, OwnerKind.IMPLEMENTATION), false, getter,
new FunctionGenerationStrategy.CodegenBased(state, getter) {
@Override
- public void doGenerateBody(ExpressionCodegen codegen, JvmMethodSignature signature) {
+ public void doGenerateBody(@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature) {
InstructionAdapter iv = codegen.v;
- iv.load(0, OBJECT_TYPE);
+ boolean forceField = AsmUtil.isPropertyWithBackingFieldInOuterClass(original) && !isClassObject(bridge.getContainingDeclaration());
+ StackValue property = codegen.intermediateValueForProperty(original, forceField, null, MethodKind.SYNTHETIC_ACCESSOR);
+ if (!forceField) {
+ iv.load(0, OBJECT_TYPE);
+ }
property.put(property.type, iv);
iv.areturn(signature.getAsmMethod().getReturnType());
}
@@ -878,12 +877,13 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
functionCodegen.generateMethod(null, typeMapper.mapSetterSignature(bridge, OwnerKind.IMPLEMENTATION), false, setter,
new FunctionGenerationStrategy.CodegenBased(state, setter) {
@Override
- public void doGenerateBody(ExpressionCodegen codegen, JvmMethodSignature signature) {
+ public void doGenerateBody(@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature) {
+ boolean forceField = AsmUtil.isPropertyWithBackingFieldInOuterClass(original) && !isClassObject(bridge.getContainingDeclaration());
+ StackValue property = codegen.intermediateValueForProperty(original, forceField, null, MethodKind.SYNTHETIC_ACCESSOR);
InstructionAdapter iv = codegen.v;
- iv.load(0, OBJECT_TYPE);
Type[] argTypes = signature.getAsmMethod().getArgumentTypes();
- for (int i = 1, reg = 1; i < argTypes.length; i++) {
+ for (int i = 0, reg = 0; i < argTypes.length; i++) {
Type argType = argTypes[i];
iv.load(reg, argType);
//noinspection AssignmentToForLoopParameter
@@ -901,6 +901,38 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
}
+ private void generateMethodCallTo(FunctionDescriptor functionDescriptor, InstructionAdapter iv) {
+ boolean isConstructor = functionDescriptor instanceof ConstructorDescriptor;
+ boolean callFromAccessor = !JetTypeMapper.isAccessor(functionDescriptor);
+ CallableMethod callableMethod = isConstructor ?
+ typeMapper.mapToCallableMethod((ConstructorDescriptor) functionDescriptor) :
+ typeMapper.mapToCallableMethod(functionDescriptor, callFromAccessor,
+ isCallInsideSameClassAsDeclared(functionDescriptor, context),
+ isCallInsideSameModuleAsDeclared(functionDescriptor, context),
+ context.getContextKind());
+
+ Method method = callableMethod.getSignature().getAsmMethod();
+ Type[] argTypes = method.getArgumentTypes();
+
+ int reg = 1;
+ if (isConstructor) {
+ iv.anew(callableMethod.getOwner().getAsmType());
+ iv.dup();
+ reg = 0;
+ }
+ else if (callFromAccessor) {
+ iv.load(0, OBJECT_TYPE);
+ }
+
+ for (int paramIndex = 0; paramIndex < argTypes.length; paramIndex++) {
+ Type argType = argTypes[paramIndex];
+ iv.load(reg, argType);
+ //noinspection AssignmentToForLoopParameter
+ reg += argType.getSize();
+ }
+ callableMethod.invokeWithoutAssertions(iv);
+ }
+
private void generateFieldForSingleton() {
boolean hasClassObject = descriptor.getClassObjectDescriptor() != null;
boolean isEnumClass = DescriptorUtils.isEnumClass(descriptor);
@@ -909,17 +941,74 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
ClassDescriptor fieldTypeDescriptor = hasClassObject ? descriptor.getClassObjectDescriptor() : descriptor;
assert fieldTypeDescriptor != null;
- final FieldInfo info = FieldInfo.createForSingleton(fieldTypeDescriptor, typeMapper);
- JetClassOrObject original = hasClassObject ? ((JetClass) myClass).getClassObject().getObjectDeclaration() : myClass;
+ StackValue.Field field = StackValue.singleton(fieldTypeDescriptor, typeMapper);
+ JetClassOrObject original;
+ if (hasClassObject) {
+ JetClassObject classObject = ((JetClass) myClass).getClassObject();
+ assert classObject != null : myClass.getText();
+ original = classObject.getObjectDeclaration();
+ }
+ else {
+ original = myClass;
+ }
- v.newField(original, ACC_PUBLIC | ACC_STATIC | ACC_FINAL, info.getFieldName(), info.getFieldType().getDescriptor(), null, null);
+ v.newField(original, ACC_PUBLIC | ACC_STATIC | ACC_FINAL, field.name, field.type.getDescriptor(), null, null);
- staticInitializerChunks.add(new CodeChunk() {
- @Override
- public void generate(InstructionAdapter iv) {
- genInitSingletonField(info, iv);
+ if (!AsmUtil.isClassObjectWithBackingFieldsInOuter(fieldTypeDescriptor)) {
+ genInitSingleton(fieldTypeDescriptor, field);
+ }
+ }
+
+ private void generateClassObjectBackingFieldCopies() {
+ if (classObjectPropertiesToCopy != null) {
+ for (PropertyAndDefaultValue propertyInfo : classObjectPropertiesToCopy) {
+ PropertyDescriptor propertyDescriptor = propertyInfo.propertyDescriptor;
+
+ v.newField(null, ACC_STATIC | ACC_FINAL | ACC_PUBLIC, context.getFieldName(propertyDescriptor),
+ typeMapper.mapType(propertyDescriptor).getDescriptor(), null, propertyInfo.defaultValue);
+
+ //This field are always static and final so if it has constant initializer don't do anything in clinit,
+ //field would be initialized via default value in v.newField(...) - see JVM SPEC Ch.4
+ if (state.getClassBuilderMode() == ClassBuilderMode.FULL && propertyInfo.defaultValue == null) {
+ ExpressionCodegen codegen = createOrGetClInitCodegen();
+ int classObjectIndex = putClassObjectInLocalVar(codegen);
+ StackValue.local(classObjectIndex, OBJECT_TYPE).put(OBJECT_TYPE, codegen.v);
+ copyFieldFromClassObject(propertyDescriptor);
+ }
}
- });
+ }
+ }
+
+ private int putClassObjectInLocalVar(ExpressionCodegen codegen) {
+ FrameMap frameMap = codegen.myFrameMap;
+ ClassDescriptor classObjectDescriptor = descriptor.getClassObjectDescriptor();
+ int classObjectIndex = frameMap.getIndex(classObjectDescriptor);
+ if (classObjectIndex == -1) {
+ classObjectIndex = frameMap.enter(classObjectDescriptor, OBJECT_TYPE);
+ StackValue classObject = StackValue.singleton(classObjectDescriptor, typeMapper);
+ classObject.put(classObject.type, codegen.v);
+ StackValue.local(classObjectIndex, classObject.type).store(classObject.type, codegen.v);
+ }
+ return classObjectIndex;
+ }
+
+ private void copyFieldFromClassObject(PropertyDescriptor propertyDescriptor) {
+ ExpressionCodegen codegen = createOrGetClInitCodegen();
+ StackValue property = codegen.intermediateValueForProperty(propertyDescriptor, false, null);
+ property.put(property.type, codegen.v);
+ StackValue.Field field = StackValue.field(property.type, JvmClassName.byClassDescriptor(descriptor),
+ propertyDescriptor.getName().asString(), true);
+ field.store(field.type, codegen.v);
+ }
+
+ protected void genInitSingleton(ClassDescriptor fieldTypeDescriptor, StackValue.Field field) {
+ if (state.getClassBuilderMode() == ClassBuilderMode.FULL) {
+ ConstructorDescriptor constructorDescriptor = DescriptorUtils.getConstructorOfSingletonObject(fieldTypeDescriptor);
+ ExpressionCodegen codegen = createOrGetClInitCodegen();
+ FunctionDescriptor fd = codegen.accessibleFunctionDescriptor(constructorDescriptor);
+ generateMethodCallTo(fd, codegen.v);
+ field.store(field.type, codegen.v);
+ }
}
protected void generatePrimaryConstructor() {
@@ -938,9 +1027,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
lookupConstructorExpressionsInClosureIfPresent(constructorContext);
}
- final JvmMethodSignature constructorSignature = typeMapper.mapConstructorSignature(constructorDescriptor, closure);
-
assert constructorDescriptor != null;
+ final JvmMethodSignature constructorSignature = typeMapper.mapConstructorSignature(constructorDescriptor, closure);
functionCodegen.generateMethod(null, constructorSignature, true, constructorDescriptor, constructorContext,
new FunctionGenerationStrategy.CodegenBased(state, constructorDescriptor) {
@@ -952,7 +1040,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
@Override
- public void doGenerateBody(ExpressionCodegen codegen, JvmMethodSignature signature) {
+ public void doGenerateBody(@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature) {
generatePrimaryConstructorImpl(callableDescriptor, codegen, closure);
}
}
@@ -963,12 +1051,16 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
CallableMethod callableMethod = typeMapper.mapToCallableMethod(constructorDescriptor, closure);
FunctionCodegen.generateConstructorWithoutParametersIfNeeded(state, callableMethod, constructorDescriptor, v);
+
+ if (isClassObject(descriptor)) {
+ context.recordSyntheticAccessorIfNeeded(constructorDescriptor, typeMapper);
+ }
}
private void generatePrimaryConstructorImpl(
- ConstructorDescriptor constructorDescriptor,
- ExpressionCodegen codegen,
- MutableClosure closure
+ @Nullable ConstructorDescriptor constructorDescriptor,
+ @NotNull ExpressionCodegen codegen,
+ @Nullable MutableClosure closure
) {
List paramDescrs = constructorDescriptor != null
? constructorDescriptor.getValueParameters()
@@ -976,7 +1068,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
InstructionAdapter iv = codegen.v;
- JvmClassName classname = JvmClassName.byType(classAsmType);
+ JvmClassName className = JvmClassName.byType(classAsmType);
if (superCall == null) {
genSimpleSuperCall(iv);
@@ -1003,7 +1095,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
if (specifier instanceof JetDelegatorByExpressionSpecifier) {
- genCallToDelegatorByExpressionSpecifier(iv, codegen, classAsmType, classname, n++, specifier);
+ genCallToDelegatorByExpressionSpecifier(iv, codegen, classAsmType, className, n++, specifier);
}
}
@@ -1015,12 +1107,24 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
Type type = typeMapper.mapType(descriptor);
iv.load(0, classAsmType);
iv.load(codegen.myFrameMap.getIndex(descriptor), type);
- iv.putfield(classAsmType.getInternalName(), descriptor.getName().asString(), type.getDescriptor());
+ iv.putfield(classAsmType.getInternalName(),
+ context.getFieldName(DescriptorUtils.getPropertyDescriptor(parameter, bindingContext)),
+ type.getDescriptor());
}
curParam++;
}
- generateInitializers(codegen, iv, myClass.getDeclarations(), bindingContext, state);
+ boolean generateInitializerInOuter = isClassObjectWithBackingFieldsInOuter(descriptor);
+ if (generateInitializerInOuter) {
+ ImplementationBodyCodegen parentCodegen = getParentBodyCodegen(this);
+ //generate object$
+ parentCodegen.genInitSingleton(descriptor, StackValue.singleton(descriptor, typeMapper));
+ parentCodegen.generateInitializers(parentCodegen.createOrGetClInitCodegen(),
+ myClass.getDeclarations(), bindingContext, state);
+ } else {
+ generateInitializers(codegen, myClass.getDeclarations(), bindingContext, state);
+ }
+
iv.visitInsn(RETURN);
}
@@ -1058,7 +1162,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
InstructionAdapter iv,
ExpressionCodegen codegen,
Type classType,
- JvmClassName classname,
+ JvmClassName className,
int n,
JetDelegationSpecifier specifier
) {
@@ -1089,14 +1193,12 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
assert superClassDescriptor != null;
- Type superTypeAsmType = typeMapper.mapType(superType, JetTypeMapperMode.IMPL);
-
StackValue field;
if (propertyDescriptor != null &&
!propertyDescriptor.isVar() &&
Boolean.TRUE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor))) {
// final property with backing field
- field = StackValue.field(typeMapper.mapType(propertyDescriptor.getType()), classname,
+ field = StackValue.field(typeMapper.mapType(propertyDescriptor.getType()), className,
propertyDescriptor.getName().asString(), false);
}
else {
@@ -1109,7 +1211,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
v.newField(specifier, ACC_PRIVATE|ACC_FINAL|ACC_SYNTHETIC, delegateField, fieldDesc, /*TODO*/null, null);
- field = StackValue.field(fieldType, classname, delegateField, false);
+ field = StackValue.field(fieldType, className, delegateField, false);
field.store(fieldType, iv);
}
@@ -1136,6 +1238,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
constructorContext.lookupInContext(descriptor, null, state, true);
} else if (isLocalNamedFun(descriptor)) {
+ assert descriptor != null;
MutableClassDescriptor classDescriptor =
(MutableClassDescriptor) constructorContext.getParentContext().getContextDescriptor();
@@ -1210,7 +1313,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
private void generateTraitMethods() {
- if (myClass instanceof JetClass && ((JetClass) myClass).isTrait()) {
+ if (JetPsiUtil.isTrait(myClass)) {
return;
}
@@ -1233,7 +1336,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
- private void generateDelegationToTraitImpl(@NotNull FunctionDescriptor fun, @NotNull FunctionDescriptor inheritedFun) {
+ private void generateDelegationToTraitImpl(final @NotNull FunctionDescriptor fun, @NotNull FunctionDescriptor inheritedFun) {
DeclarationDescriptor containingDeclaration = fun.getContainingDeclaration();
if (!(containingDeclaration instanceof ClassDescriptor)) {
return;
@@ -1250,20 +1353,21 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
Method methodToGenerate = delegateInfo.methodToGenerate;
Method methodInTrait = delegateInfo.methodInTrait;
- MethodVisitor mv = v.newMethod(myClass, flags, methodToGenerate.getName(), methodToGenerate.getDescriptor(), null, null);
+ PsiElement origin = descriptorToDeclaration(bindingContext, fun);
+ MethodVisitor mv = v.newMethod(origin, flags, methodToGenerate.getName(), methodToGenerate.getDescriptor(), null, null);
AnnotationCodegen.forMethod(mv, typeMapper).genAnnotations(fun);
- writeAnnotationForDelegateToTraitImpl(fun, inheritedFun, mv);
-
if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
genStubCode(mv);
}
else if (state.getClassBuilderMode() == ClassBuilderMode.FULL) {
+ writeAnnotationForDelegateToTraitImpl(fun, inheritedFun, mv);
+
Type returnType = methodToGenerate.getReturnType();
mv.visitCode();
FrameMap frameMap = context.prepareFrame(typeMapper);
- ExpressionCodegen codegen = new ExpressionCodegen(mv, frameMap, returnType, context, state);
+ ExpressionCodegen codegen = new ExpressionCodegen(mv, frameMap, returnType, context.intoFunction(inheritedFun), state);
codegen.generateThisOrOuter(descriptor, false); // ??? wouldn't it be addClosureToConstructorParameters good idea to put it?
Type[] argTypes = methodToGenerate.getArgumentTypes();
@@ -1397,42 +1501,32 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private static int findFirstSuperArgument(CallableMethod method) {
List types = method.getSignature().getKotlinParameterTypes();
- if (types != null) {
- int i = 0;
- for (JvmMethodParameterSignature type : types) {
- if (type.getKind() == JvmMethodParameterKind.SUPER_CALL_PARAM) {
- return i + 1; // because of this
- }
- i += type.getAsmType().getSize();
+ int i = 0;
+ for (JvmMethodParameterSignature type : types) {
+ if (type.getKind() == JvmMethodParameterKind.SUPER_CALL_PARAM) {
+ return i + 1; // because of this
}
+ i += type.getAsmType().getSize();
}
return -1;
}
@Override
- protected void generateDeclaration(PropertyCodegen propertyCodegen, JetDeclaration declaration, FunctionCodegen functionCodegen) {
+ protected void generateDeclaration(PropertyCodegen propertyCodegen, JetDeclaration declaration) {
if (declaration instanceof JetEnumEntry) {
String name = declaration.getName();
String desc = "L" + classAsmType.getInternalName() + ";";
v.newField(declaration, ACC_PUBLIC | ACC_ENUM | ACC_STATIC | ACC_FINAL, name, desc, null, null);
- if (myEnumConstants.isEmpty()) {
- staticInitializerChunks.add(new CodeChunk() {
- @Override
- public void generate(InstructionAdapter v) {
- initializeEnumConstants(v);
- }
- });
- }
myEnumConstants.add((JetEnumEntry) declaration);
}
- super.generateDeclaration(propertyCodegen, declaration, functionCodegen);
+ super.generateDeclaration(propertyCodegen, declaration);
}
private final List myEnumConstants = new ArrayList();
- private void initializeEnumConstants(InstructionAdapter iv) {
- ExpressionCodegen codegen = new ExpressionCodegen(iv, new FrameMap(), Type.VOID_TYPE, context, state);
+ private void initializeEnumConstants(ExpressionCodegen codegen) {
+ InstructionAdapter iv = codegen.v;
int ordinal = -1;
JetType myType = descriptor.getDefaultType();
Type myAsmType = typeMapper.mapType(myType, JetTypeMapperMode.IMPL);
@@ -1494,14 +1588,14 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
public static void generateInitializers(
- @NotNull ExpressionCodegen codegen, @NotNull InstructionAdapter iv, @NotNull List declarations,
+ @NotNull ExpressionCodegen codegen, @NotNull List declarations,
@NotNull BindingContext bindingContext, @NotNull GenerationState state
) {
JetTypeMapper typeMapper = state.getTypeMapper();
for (JetDeclaration declaration : declarations) {
if (declaration instanceof JetProperty) {
if (shouldInitializeProperty((JetProperty) declaration, typeMapper)) {
- initializeProperty(codegen, bindingContext, iv, (JetProperty) declaration, false);
+ initializeProperty(codegen, bindingContext, (JetProperty) declaration);
}
}
else if (declaration instanceof JetClassInitializer) {
@@ -1510,16 +1604,12 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
}
+
public static void initializeProperty(
@NotNull ExpressionCodegen codegen,
@NotNull BindingContext bindingContext,
- @NotNull InstructionAdapter iv,
- @NotNull JetProperty property,
- boolean isStatic
+ @NotNull JetProperty property
) {
- if (!isStatic) {
- iv.load(0, OBJECT_TYPE);
- }
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) bindingContext.get(BindingContext.VARIABLE, property);
assert propertyDescriptor != null;
@@ -1528,14 +1618,29 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
assert initializer != null : "shouldInitializeProperty must return false if initializer is null";
JetType jetType = getPropertyOrDelegateType(bindingContext, property, propertyDescriptor);
+
+ StackValue.StackValueWithSimpleReceiver propValue = codegen.intermediateValueForProperty(propertyDescriptor, true, null, MethodKind.INITIALIZER);
+
+ if (!propValue.isStatic) {
+ codegen.v.load(0, OBJECT_TYPE);
+ }
+
Type type = codegen.expressionType(initializer);
if (jetType.isNullable()) {
type = boxType(type);
}
codegen.gen(initializer, type);
- StackValue.Property propValue = codegen.intermediateValueForProperty(propertyDescriptor, true, null);
- propValue.store(type, iv);
+ propValue.store(type, codegen.v);
+ }
+
+ public static boolean shouldWriteFieldInitializer(PropertyDescriptor descriptor, JetTypeMapper mapper) {
+ //final field of primitive or String type
+ if (!descriptor.isVar()) {
+ Type type = mapper.mapType(descriptor.getType());
+ return AsmUtil.isPrimitive(type) || "java.lang.String".equals(type.getClassName());
+ }
+ return false;
}
public static boolean shouldInitializeProperty(
@@ -1551,6 +1656,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) typeMapper.getBindingContext().get(BindingContext.VARIABLE, property);
assert propertyDescriptor != null;
+ //TODO: OPTIMIZATION: don't initialize static final fields
+
Object value = compileTimeValue.getValue();
JetType jetType = getPropertyOrDelegateType(typeMapper.getBindingContext(), property, propertyDescriptor);
Type type = typeMapper.mapType(jetType);
@@ -1568,7 +1675,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
return descriptor.getType();
}
- private static boolean skipDefaultValue(PropertyDescriptor propertyDescriptor, Object value, Type type) {
+ private static boolean skipDefaultValue(@NotNull PropertyDescriptor propertyDescriptor, Object value, @NotNull Type type) {
if (isPrimitive(type)) {
if (!propertyDescriptor.getType().isNullable() && value instanceof Number) {
if (type == Type.INT_TYPE && ((Number) value).intValue() == 0) {
@@ -1636,7 +1743,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private List> getTraitImplementations(@NotNull ClassDescriptor classDescriptor) {
List> r = Lists.newArrayList();
- root:
for (DeclarationDescriptor decl : classDescriptor.getDefaultType().getMemberScope().getAllDescriptors()) {
if (!(decl instanceof CallableMemberDescriptor)) {
continue;
@@ -1667,7 +1773,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
continue;
}
- assert count == 1 : "Ambiguous overriden declaration: " + callableMemberDescriptor.getName();
+ assert count == 1 : "Ambiguous overridden declaration: " + callableMemberDescriptor.getName();
Collection superTypesOfSuperClass =
@@ -1684,4 +1790,25 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
return r;
}
+ public void addClassObjectPropertyToCopy(PropertyDescriptor descriptor, Object defaultValue) {
+ if (classObjectPropertiesToCopy == null) {
+ classObjectPropertiesToCopy = new ArrayList();
+ }
+ classObjectPropertiesToCopy.add(new PropertyAndDefaultValue(descriptor, defaultValue));
+ }
+
+ static class PropertyAndDefaultValue {
+
+ PropertyAndDefaultValue(PropertyDescriptor propertyDescriptor, Object defaultValue) {
+ this.propertyDescriptor = propertyDescriptor;
+ this.defaultValue = defaultValue;
+ }
+
+ private PropertyDescriptor propertyDescriptor;
+
+ private Object defaultValue;
+
+
+ }
+
}
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/MemberCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/MemberCodegen.java
index 89627161c90..255b476a9de 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/MemberCodegen.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/MemberCodegen.java
@@ -17,26 +17,35 @@
package org.jetbrains.jet.codegen;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.jet.codegen.context.ClassContext;
import org.jetbrains.jet.codegen.context.CodegenContext;
+import org.jetbrains.jet.codegen.context.FieldOwnerContext;
import org.jetbrains.jet.codegen.state.GenerationState;
import org.jetbrains.jet.codegen.state.GenerationStateAware;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
-import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.types.ErrorUtils;
-import java.util.Map;
-
-import static org.jetbrains.jet.codegen.binding.CodegenBinding.enumEntryNeedSubclass;
public class MemberCodegen extends GenerationStateAware {
- public MemberCodegen(@NotNull GenerationState state) {
+
+ @Nullable
+ private MemberCodegen parentCodegen;
+
+ public MemberCodegen(@NotNull GenerationState state, @Nullable MemberCodegen parentCodegen) {
super(state);
+ this.parentCodegen = parentCodegen;
+ }
+
+ @Nullable
+ public MemberCodegen getParentCodegen() {
+ return parentCodegen;
}
public void genFunctionOrProperty(
- CodegenContext context,
+ @NotNull FieldOwnerContext context,
@NotNull JetTypeParameterListOwner functionOrProperty,
@NotNull ClassBuilder classBuilder
) {
@@ -54,7 +63,7 @@ public class MemberCodegen extends GenerationStateAware {
}
else if (functionOrProperty instanceof JetProperty) {
try {
- new PropertyCodegen(context, classBuilder, functionCodegen).gen((JetProperty) functionOrProperty);
+ new PropertyCodegen(context, classBuilder, functionCodegen, this).gen((JetProperty) functionOrProperty);
}
catch (CompilationException e) {
throw e;
@@ -80,8 +89,8 @@ public class MemberCodegen extends GenerationStateAware {
}
ClassBuilder classBuilder = state.getFactory().forClassImplementation(descriptor, aClass.getContainingFile());
- CodegenContext classContext = parentContext.intoClass(descriptor, OwnerKind.IMPLEMENTATION, state);
- new ImplementationBodyCodegen(aClass, classContext, classBuilder, state).generate();
+ ClassContext classContext = parentContext.intoClass(descriptor, OwnerKind.IMPLEMENTATION, state);
+ new ImplementationBodyCodegen(aClass, classContext, classBuilder, state, this).generate();
classBuilder.done();
if (aClass instanceof JetClass && ((JetClass) aClass).isTrait()) {
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/MethodKind.java b/compiler/backend/src/org/jetbrains/jet/codegen/MethodKind.java
new file mode 100644
index 00000000000..e0d1634880a
--- /dev/null
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/MethodKind.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.codegen;
+
+public enum MethodKind {
+ GENERAL,
+ INITIALIZER,
+ SYNTHETIC_ACCESSOR
+}
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java
index 7c3e2e34336..1cfe73b0f10 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java
@@ -22,24 +22,29 @@ import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
+import com.intellij.util.PathUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.asm4.AnnotationVisitor;
import org.jetbrains.asm4.MethodVisitor;
import org.jetbrains.asm4.Type;
-import org.jetbrains.asm4.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.context.CodegenContext;
+import org.jetbrains.jet.codegen.context.FieldOwnerContext;
import org.jetbrains.jet.codegen.state.GenerationState;
-import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
-import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
+import org.jetbrains.jet.lang.descriptors.*;
+import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
+import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
-import org.jetbrains.jet.lang.resolve.java.*;
+import org.jetbrains.jet.lang.resolve.java.JvmAbi;
+import org.jetbrains.jet.lang.resolve.java.JvmClassName;
+import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
+import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.Name;
-import java.io.File;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import static org.jetbrains.asm4.Opcodes.*;
@@ -56,7 +61,7 @@ public class NamespaceCodegen extends MemberCodegen {
GenerationState state,
Collection namespaceFiles
) {
- super(state);
+ super(state, null);
checkAllFilesHaveSameNamespace(namespaceFiles);
this.v = v;
@@ -146,22 +151,20 @@ public class NamespaceCodegen extends MemberCodegen {
);
builder.visitSource(file.getName(), null);
+ FieldOwnerContext nameSpaceContext =
+ CodegenContext.STATIC.intoNamespace(descriptor);
+
+ FieldOwnerContext nameSpacePart =
+ CodegenContext.STATIC.intoNamespacePart(className, descriptor);
+
for (JetDeclaration declaration : file.getDeclarations()) {
if (declaration instanceof JetNamedFunction || declaration instanceof JetProperty) {
- {
- CodegenContext context =
- CodegenContext.STATIC.intoNamespace(descriptor);
- genFunctionOrProperty(context, (JetTypeParameterListOwner) declaration, builder);
- }
- {
- CodegenContext context =
- CodegenContext.STATIC.intoNamespacePart(className, descriptor);
- genFunctionOrProperty(context, (JetTypeParameterListOwner) declaration, v.getClassBuilder());
- }
+ genFunctionOrProperty(nameSpaceContext, (JetTypeParameterListOwner) declaration, builder);
+ genFunctionOrProperty(nameSpacePart, (JetTypeParameterListOwner) declaration, v.getClassBuilder());
}
}
- generateStaticInitializers(builder, file);
+ generateStaticInitializers(descriptor, builder, file, nameSpaceContext);
builder.done();
}
@@ -205,20 +208,33 @@ public class NamespaceCodegen extends MemberCodegen {
}
}
- private void generateStaticInitializers(@NotNull ClassBuilder builder, @NotNull JetFile file) {
+ private void generateStaticInitializers(
+ NamespaceDescriptor descriptor,
+ @NotNull ClassBuilder builder,
+ @NotNull JetFile file,
+ @NotNull FieldOwnerContext context
+ ) {
List properties = collectPropertiesToInitialize(file);
if (properties.isEmpty()) return;
- MethodVisitor mv = builder.newMethod(file, ACC_PUBLIC | ACC_STATIC, "", "()V", null, null);
+ MethodVisitor mv = builder.newMethod(file, ACC_STATIC, "", "()V", null, null);
if (state.getClassBuilderMode() == ClassBuilderMode.FULL) {
mv.visitCode();
FrameMap frameMap = new FrameMap();
- ExpressionCodegen codegen = new ExpressionCodegen(mv, frameMap, Type.VOID_TYPE, CodegenContext.STATIC, state);
+
+ SimpleFunctionDescriptorImpl clInit =
+ new SimpleFunctionDescriptorImpl(descriptor, Collections.emptyList(),
+ Name.special(""),
+ CallableMemberDescriptor.Kind.SYNTHESIZED);
+ clInit.initialize(null, null, Collections.emptyList(),
+ Collections.emptyList(), null, null, Visibilities.PRIVATE, false);
+
+ ExpressionCodegen codegen = new ExpressionCodegen(mv, frameMap, Type.VOID_TYPE, context.intoFunction(clInit), state);
for (JetDeclaration declaration : properties) {
ImplementationBodyCodegen.
- initializeProperty(codegen, state.getBindingContext(), new InstructionAdapter(mv), (JetProperty) declaration, true);
+ initializeProperty(codegen, state.getBindingContext(), (JetProperty) declaration);
}
mv.visitInsn(RETURN);
@@ -255,20 +271,11 @@ public class NamespaceCodegen extends MemberCodegen {
@NotNull
private static String getMultiFileNamespaceInternalName(@NotNull String namespaceInternalName, @NotNull PsiFile file) {
- String name = FileUtil.toSystemDependentName(file.getName());
+ String fileName = FileUtil.getNameWithoutExtension(PathUtil.getFileName(file.getName()));
- int substringFrom = name.lastIndexOf(File.separator) + 1;
-
- int substringTo = name.lastIndexOf('.');
- if (substringTo == -1) {
- substringTo = name.length();
- }
-
- int pathHashCode = FileUtil.toSystemDependentName(file.getVirtualFile().getCanonicalPath()).hashCode();
-
- // dollar sign in the end is to prevent synthetic class from having "Test" or other parseable suffix
// path hashCode to prevent same name / different path collision
- return namespaceInternalName + "$src$" + replaceSpecialSymbols(name.substring(substringFrom, substringTo)) + "$" + pathHashCode;
+ return namespaceInternalName + "$src$" + replaceSpecialSymbols(fileName) + "$" + Integer.toHexString(
+ CodegenUtil.getPathHashCode(file));
}
private static String replaceSpecialSymbols(@NotNull String str) {
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/PropertyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/PropertyCodegen.java
index 34c71c9655b..7ef0cf02f4f 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/PropertyCodegen.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/PropertyCodegen.java
@@ -17,23 +17,25 @@
package org.jetbrains.jet.codegen;
import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.jetbrains.asm4.FieldVisitor;
import org.jetbrains.asm4.MethodVisitor;
import org.jetbrains.asm4.Type;
import org.jetbrains.asm4.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.context.CodegenContext;
-import org.jetbrains.jet.codegen.context.MethodContext;
+import org.jetbrains.jet.codegen.context.FieldOwnerContext;
import org.jetbrains.jet.codegen.signature.JvmMethodSignature;
import org.jetbrains.jet.codegen.signature.JvmPropertyAccessorSignature;
import org.jetbrains.jet.codegen.signature.kotlin.JetMethodAnnotationWriter;
+import org.jetbrains.jet.codegen.state.GenerationState;
import org.jetbrains.jet.codegen.state.GenerationStateAware;
import org.jetbrains.jet.codegen.state.JetTypeMapper;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
+import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
@@ -46,37 +48,52 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import static org.jetbrains.asm4.Opcodes.*;
import static org.jetbrains.jet.codegen.AsmUtil.getDeprecatedAccessFlag;
+import static org.jetbrains.jet.codegen.AsmUtil.getVisibilityForSpecialPropertyBackingField;
import static org.jetbrains.jet.codegen.CodegenUtil.*;
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.OBJECT_TYPE;
public class PropertyCodegen extends GenerationStateAware {
+ @NotNull
private final FunctionCodegen functionCodegen;
+
+ @NotNull
private final ClassBuilder v;
- private final CodegenContext context;
+
+ @NotNull
+ private final FieldOwnerContext context;
+
+ @Nullable
+ private MemberCodegen classBodyCodegen;
+
+ @NotNull
private final OwnerKind kind;
- public PropertyCodegen(CodegenContext context, ClassBuilder v, FunctionCodegen functionCodegen) {
+ public PropertyCodegen(
+ @NotNull FieldOwnerContext context,
+ @NotNull ClassBuilder v,
+ @NotNull FunctionCodegen functionCodegen,
+ @Nullable MemberCodegen classBodyCodegen
+ ) {
super(functionCodegen.getState());
this.v = v;
this.functionCodegen = functionCodegen;
this.context = context;
+ this.classBodyCodegen = classBodyCodegen;
this.kind = context.getContextKind();
}
public void gen(JetProperty p) {
- VariableDescriptor descriptor = bindingContext.get(BindingContext.VARIABLE, p);
- if (!(descriptor instanceof PropertyDescriptor)) {
- throw new UnsupportedOperationException("expect a property to have a property descriptor");
- }
- PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
+ PropertyDescriptor propertyDescriptor = DescriptorUtils.getPropertyDescriptor(p, bindingContext);
assert kind instanceof OwnerKind.StaticDelegateKind || kind == OwnerKind.NAMESPACE || kind == OwnerKind.IMPLEMENTATION || kind == OwnerKind.TRAIT_IMPL
- : "Generating property with a wrong kind (" + kind + "): " + descriptor;
+ : "Generating property with a wrong kind (" + kind + "): " + propertyDescriptor;
if (kind != OwnerKind.TRAIT_IMPL && !(kind instanceof OwnerKind.StaticDelegateKind)) {
generateBackingField(p, propertyDescriptor);
}
generateGetter(p, propertyDescriptor, p.getGetter());
generateSetter(p, propertyDescriptor, p.getSetter());
+
+ context.recordSyntheticAccessorIfNeeded(propertyDescriptor, typeMapper);
}
public void generatePrimaryConstructorProperty(JetParameter p, PropertyDescriptor descriptor) {
@@ -87,7 +104,7 @@ public class PropertyCodegen extends GenerationStateAware {
}
}
- private void generateBackingField(PsiElement p, PropertyDescriptor propertyDescriptor) {
+ private void generateBackingField(JetNamedDeclaration p, PropertyDescriptor propertyDescriptor) {
//noinspection ConstantConditions
boolean hasBackingField = bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor);
boolean isDelegated = p instanceof JetProperty && ((JetProperty) p).getDelegateExpression() != null;
@@ -106,49 +123,70 @@ public class PropertyCodegen extends GenerationStateAware {
}
- private FieldVisitor generatePropertyDelegateAccess(JetProperty p, PropertyDescriptor propertyDescriptor) {
- int modifiers = ACC_PRIVATE | ACC_FINAL | getDeprecatedAccessFlag(propertyDescriptor);
- if (kind == OwnerKind.NAMESPACE) {
- modifiers |= ACC_STATIC;
- }
+ private FieldVisitor generateBackingField(JetNamedDeclaration element, PropertyDescriptor propertyDescriptor, boolean isDelegate, JetType jetType, Object defaultValue) {
+ int modifiers = getDeprecatedAccessFlag(propertyDescriptor);
+
if (KotlinBuiltIns.getInstance().isVolatile(propertyDescriptor)) {
modifiers |= ACC_VOLATILE;
}
+
+ if (kind == OwnerKind.NAMESPACE) {
+ modifiers |= ACC_STATIC;
+ }
+
+ if (!propertyDescriptor.isVar() || isDelegate) {
+ modifiers |= ACC_FINAL;
+ }
+
+ Type type = typeMapper.mapType(jetType);
+
+ ClassBuilder builder = v;
+
+ FieldOwnerContext backingFieldContext = context;
+ if (AsmUtil.isPropertyWithBackingFieldInOuterClass(propertyDescriptor)) {
+ modifiers |= ACC_STATIC | getVisibilityForSpecialPropertyBackingField(propertyDescriptor, isDelegate);
+ ImplementationBodyCodegen codegen = getParentBodyCodegen(classBodyCodegen);
+ builder = codegen.v;
+ backingFieldContext = codegen.context;
+ } else {
+ if (kind != OwnerKind.NAMESPACE || isDelegate) {
+ modifiers |= ACC_PRIVATE;
+ }
+ }
+
+ if (AsmUtil.isPropertyWithBackingFieldCopyInOuterClass(propertyDescriptor)) {
+ ImplementationBodyCodegen parentBodyCodegen = getParentBodyCodegen(classBodyCodegen);
+ parentBodyCodegen.addClassObjectPropertyToCopy(propertyDescriptor, defaultValue);
+ }
+
+ String name = backingFieldContext.getFieldName(propertyDescriptor, isDelegate);
+
+ return builder.newField(element, modifiers, name, type.getDescriptor(),
+ typeMapper.mapFieldSignature(jetType), defaultValue);
+ }
+
+ private FieldVisitor generatePropertyDelegateAccess(JetProperty p, PropertyDescriptor propertyDescriptor) {
JetType delegateType = bindingContext.get(BindingContext.EXPRESSION_TYPE, p.getDelegateExpression());
if (delegateType == null) {
// If delegate expression is unresolved reference
delegateType = ErrorUtils.createErrorType("Delegate type");
}
- Type type = typeMapper.mapType(delegateType);
- return v.newField(p, modifiers, JvmAbi.getPropertyDelegateName(propertyDescriptor.getName()), type.getDescriptor(),
- null, null);
+
+ return generateBackingField(p, propertyDescriptor, true, delegateType, null);
}
- private FieldVisitor generateBackingFieldAccess(PsiElement p, PropertyDescriptor propertyDescriptor) {
+ private FieldVisitor generateBackingFieldAccess(JetNamedDeclaration p, PropertyDescriptor propertyDescriptor) {
Object value = null;
- if (p instanceof JetProperty && !ImplementationBodyCodegen.shouldInitializeProperty((JetProperty) p, typeMapper)) {
- JetExpression initializer = ((JetProperty) p).getInitializer();
+
+ if (ImplementationBodyCodegen.shouldWriteFieldInitializer(propertyDescriptor, typeMapper)) {
+ JetExpression initializer = p instanceof JetProperty ? ((JetProperty) p).getInitializer() : null;
if (initializer != null) {
CompileTimeConstant> compileTimeValue = bindingContext.get(BindingContext.COMPILE_TIME_VALUE, initializer);
value = compileTimeValue != null ? compileTimeValue.getValue() : null;
}
}
- int modifiers;
- if (kind == OwnerKind.NAMESPACE) {
- modifiers = ACC_STATIC;
- }
- else {
- modifiers = ACC_PRIVATE;
- }
- if (!propertyDescriptor.isVar()) {
- modifiers |= ACC_FINAL;
- }
- modifiers |= getDeprecatedAccessFlag(propertyDescriptor);
- if (KotlinBuiltIns.getInstance().isVolatile(propertyDescriptor)) {
- modifiers |= ACC_VOLATILE;
- }
- Type type = typeMapper.mapType(propertyDescriptor);
- return v.newField(p, modifiers, propertyDescriptor.getName().asString(), type.getDescriptor(), null, value);
+
+ return generateBackingField(p, propertyDescriptor, false, propertyDescriptor.getType(), value);
}
private void generateGetter(JetNamedDeclaration p, PropertyDescriptor propertyDescriptor, JetPropertyAccessor getter) {
@@ -164,10 +202,10 @@ public class PropertyCodegen extends GenerationStateAware {
FunctionGenerationStrategy strategy;
if (defaultGetter) {
if (p instanceof JetProperty && ((JetProperty) p).getDelegateExpression() != null) {
- strategy = new DefaultPropertyWithDelegateAccessorStrategy(getterDescriptor);
+ strategy = new DefaultPropertyWithDelegateAccessorStrategy(state, getterDescriptor);
}
else {
- strategy = new DefaultPropertyAccessorStrategy(getterDescriptor);
+ strategy = new DefaultPropertyAccessorStrategy(state, getterDescriptor);
}
}
else {
@@ -195,10 +233,10 @@ public class PropertyCodegen extends GenerationStateAware {
FunctionGenerationStrategy strategy;
if (defaultSetter) {
if (p instanceof JetProperty && ((JetProperty) p).getDelegateExpression() != null) {
- strategy = new DefaultPropertyWithDelegateAccessorStrategy(setterDescriptor);
+ strategy = new DefaultPropertyWithDelegateAccessorStrategy(state, setterDescriptor);
}
else {
- strategy = new DefaultPropertyAccessorStrategy(setterDescriptor);
+ strategy = new DefaultPropertyAccessorStrategy(state, setterDescriptor);
}
}
else {
@@ -214,97 +252,89 @@ public class PropertyCodegen extends GenerationStateAware {
}
- private class DefaultPropertyAccessorStrategy extends FunctionGenerationStrategy {
- private final PropertyAccessorDescriptor descriptor;
+ private static class DefaultPropertyAccessorStrategy extends FunctionGenerationStrategy.CodegenBased {
- public DefaultPropertyAccessorStrategy(@NotNull PropertyAccessorDescriptor descriptor) {
- this.descriptor = descriptor;
+ public DefaultPropertyAccessorStrategy(
+ @NotNull GenerationState state,
+ @NotNull PropertyAccessorDescriptor callableDescriptor
+ ) {
+ super(state, callableDescriptor);
}
@Override
- public void generateBody(
- @NotNull MethodVisitor mv,
- @NotNull JvmMethodSignature signature,
- @NotNull MethodContext context
+ public void doGenerateBody(
+ ExpressionCodegen codegen, JvmMethodSignature signature
) {
- generateDefaultAccessor(descriptor, new InstructionAdapter(mv), typeMapper, context);
+ generateDefaultAccessor(callableDescriptor, codegen.v, codegen);
}
}
private static void generateDefaultAccessor(
@NotNull PropertyAccessorDescriptor accessorDescriptor,
@NotNull InstructionAdapter iv,
- @NotNull JetTypeMapper typeMapper,
- @NotNull CodegenContext context
+ @NotNull ExpressionCodegen codegen
) {
+ JetTypeMapper typeMapper = codegen.typeMapper;
+ CodegenContext context = codegen.context;
OwnerKind kind = context.getContextKind();
PropertyDescriptor propertyDescriptor = accessorDescriptor.getCorrespondingProperty();
Type type = typeMapper.mapType(propertyDescriptor);
+
+ int paramCode = 0;
+ if (kind != OwnerKind.NAMESPACE) {
+ iv.load(0, OBJECT_TYPE);
+ paramCode = 1;
+ }
+
+ StackValue property = codegen.intermediateValueForProperty(accessorDescriptor.getCorrespondingProperty(), true, null);
+
if (accessorDescriptor instanceof PropertyGetterDescriptor) {
- if (kind != OwnerKind.NAMESPACE) {
- iv.load(0, OBJECT_TYPE);
- }
- iv.visitFieldInsn(
- kind == OwnerKind.NAMESPACE ? GETSTATIC : GETFIELD,
- typeMapper.getOwner(propertyDescriptor, kind, isCallInsideSameModuleAsDeclared(propertyDescriptor, context)).getInternalName(),
- propertyDescriptor.getName().asString(),
- type.getDescriptor());
+ property.put(type, iv);
iv.areturn(type);
}
else if (accessorDescriptor instanceof PropertySetterDescriptor) {
- int paramCode = 0;
- if (kind != OwnerKind.NAMESPACE) {
- iv.load(0, OBJECT_TYPE);
- paramCode = 1;
- }
ReceiverParameterDescriptor receiverParameter = propertyDescriptor.getReceiverParameter();
if (receiverParameter != null) {
paramCode += typeMapper.mapType(receiverParameter.getType()).getSize();
}
iv.load(paramCode, type);
- iv.visitFieldInsn(kind == OwnerKind.NAMESPACE ? PUTSTATIC : PUTFIELD,
- typeMapper.getOwner(propertyDescriptor, kind, isCallInsideSameModuleAsDeclared(propertyDescriptor, context)).getInternalName(),
- propertyDescriptor.getName().asString(),
- type.getDescriptor());
+ property.store(type, iv);
iv.visitInsn(RETURN);
} else {
assert false : "Unreachable state";
}
}
- private class DefaultPropertyWithDelegateAccessorStrategy extends FunctionGenerationStrategy {
- private final PropertyAccessorDescriptor descriptor;
-
- public DefaultPropertyWithDelegateAccessorStrategy(@NotNull PropertyAccessorDescriptor descriptor) {
- this.descriptor = descriptor;
+ private static class DefaultPropertyWithDelegateAccessorStrategy extends FunctionGenerationStrategy.CodegenBased {
+ public DefaultPropertyWithDelegateAccessorStrategy(@NotNull GenerationState state, @NotNull PropertyAccessorDescriptor descriptor) {
+ super(state, descriptor);
}
@Override
- public void generateBody(
- @NotNull MethodVisitor mv,
- @NotNull JvmMethodSignature signature,
- @NotNull MethodContext context
+ public void doGenerateBody(
+ @NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature
) {
- InstructionAdapter iv = new InstructionAdapter(mv);
- ExpressionCodegen codegen = new ExpressionCodegen(
- mv, getFrameMap(typeMapper, context), signature.getAsmMethod().getReturnType(), context, state);
+ JetTypeMapper typeMapper = codegen.typeMapper;
+ OwnerKind kind = codegen.context.getContextKind();
+ InstructionAdapter iv = codegen.v;
+ BindingContext bindingContext = state.getBindingContext();
ResolvedCall resolvedCall =
- bindingContext.get(BindingContext.DELEGATED_PROPERTY_RESOLVED_CALL, descriptor);
+ bindingContext.get(BindingContext.DELEGATED_PROPERTY_RESOLVED_CALL, callableDescriptor);
- Call call = bindingContext.get(BindingContext.DELEGATED_PROPERTY_CALL, descriptor);
+ Call call = bindingContext.get(BindingContext.DELEGATED_PROPERTY_CALL, callableDescriptor);
assert call != null : "Call should be recorded for delegate call " + signature.toString();
- PropertyDescriptor property = descriptor.getCorrespondingProperty();
+ PropertyDescriptor property = callableDescriptor.getCorrespondingProperty();
Type asmType = typeMapper.mapType(property);
if (kind != OwnerKind.NAMESPACE) {
iv.load(0, OBJECT_TYPE);
}
- StackValue.Property delegatedProperty = codegen.intermediateValueForProperty(property, true, null);
+ StackValue delegatedProperty = codegen.intermediateValueForProperty(property, true, null);
StackValue lastValue = codegen.invokeFunction(call, delegatedProperty, resolvedCall);
if (lastValue.type != Type.VOID_TYPE) {
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/SamCodegenUtil.java b/compiler/backend/src/org/jetbrains/jet/codegen/SamCodegenUtil.java
new file mode 100644
index 00000000000..9b967cd5918
--- /dev/null
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/SamCodegenUtil.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.codegen;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
+import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor;
+import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
+import org.jetbrains.jet.lang.resolve.BindingContext;
+import org.jetbrains.jet.lang.resolve.java.JavaBindingContext;
+
+public class SamCodegenUtil {
+ @Nullable
+ public static FunctionDescriptor getOriginalIfSamAdapter(@NotNull BindingContext bindingContext, @NotNull CallableDescriptor fun) {
+ if (!(fun instanceof FunctionDescriptor)) {
+ return null;
+ }
+ FunctionDescriptor original = ((FunctionDescriptor) fun).getOriginal();
+ if (original.getKind() == CallableMemberDescriptor.Kind.SYNTHESIZED) {
+ return bindingContext.get(JavaBindingContext.SAM_ADAPTER_FUNCTION_TO_ORIGINAL, original);
+ }
+ if (original.getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
+ for (FunctionDescriptor overridden : original.getOverriddenDescriptors()) {
+ FunctionDescriptor originalIfSamAdapter = getOriginalIfSamAdapter(bindingContext, overridden);
+ if (originalIfSamAdapter != null) {
+ return originalIfSamAdapter;
+ }
+ }
+ }
+ return null;
+ }
+
+ private SamCodegenUtil() {
+ }
+}
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/SamWrapperClasses.java b/compiler/backend/src/org/jetbrains/jet/codegen/SamWrapperClasses.java
new file mode 100644
index 00000000000..874ac019ee8
--- /dev/null
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/SamWrapperClasses.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.codegen;
+
+import com.google.common.collect.Maps;
+import com.intellij.openapi.util.Factory;
+import com.intellij.openapi.util.Pair;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.jet.codegen.state.GenerationState;
+import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
+import org.jetbrains.jet.lang.psi.JetExpression;
+import org.jetbrains.jet.lang.psi.JetFile;
+import org.jetbrains.jet.lang.resolve.java.JvmClassName;
+import org.jetbrains.jet.lang.resolve.java.descriptor.ClassDescriptorFromJvmBytecode;
+
+import java.util.Map;
+
+public class SamWrapperClasses {
+ private final GenerationState state;
+
+ private final Map, JvmClassName> samInterfaceToWrapperClass = Maps.newHashMap();
+
+ public SamWrapperClasses(GenerationState state) {
+ this.state = state;
+ }
+
+ @NotNull
+ public JvmClassName getSamWrapperClass(@NotNull final ClassDescriptorFromJvmBytecode samInterface, @NotNull final JetFile file) {
+ return ContainerUtil.getOrCreate(samInterfaceToWrapperClass, Pair.create(samInterface, file),
+ new Factory() {
+ @Override
+ public JvmClassName create() {
+ return new SamWrapperCodegen(state, samInterface).genWrapper(file);
+ }
+ });
+ }
+}
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/SamWrapperCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/SamWrapperCodegen.java
index 950b4543c73..1e90036254c 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/SamWrapperCodegen.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/SamWrapperCodegen.java
@@ -20,24 +20,23 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.asm4.MethodVisitor;
import org.jetbrains.asm4.Type;
import org.jetbrains.asm4.commons.InstructionAdapter;
-import org.jetbrains.jet.codegen.binding.CodegenBinding;
import org.jetbrains.jet.codegen.context.CodegenContext;
import org.jetbrains.jet.codegen.state.GenerationState;
import org.jetbrains.jet.codegen.state.GenerationStateAware;
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
-import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
-import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
+import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
-import org.jetbrains.jet.lang.psi.JetCallExpression;
-import org.jetbrains.jet.lang.psi.JetExpression;
+import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.resolve.BindingContext;
-import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
+import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
+import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
+import org.jetbrains.jet.lang.resolve.java.descriptor.ClassDescriptorFromJvmBytecode;
import org.jetbrains.jet.lang.resolve.java.sam.SingleAbstractMethodUtils;
+import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.types.JetType;
-import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import static org.jetbrains.asm4.Opcodes.*;
import static org.jetbrains.jet.codegen.AsmUtil.NO_FLAG_PACKAGE_PRIVATE;
@@ -47,40 +46,25 @@ import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.OBJECT_TYPE;
public class SamWrapperCodegen extends GenerationStateAware {
private static final String FUNCTION_FIELD_NAME = "function";
- @NotNull private final ClassDescriptor samInterface;
+ @NotNull private final ClassDescriptorFromJvmBytecode samInterface;
- public SamWrapperCodegen(@NotNull GenerationState state, @NotNull ClassDescriptor samInterface) {
+ public SamWrapperCodegen(@NotNull GenerationState state, @NotNull ClassDescriptorFromJvmBytecode samInterface) {
super(state);
this.samInterface = samInterface;
}
- public JvmClassName genWrapper(JetCallExpression callExpression, JetExpression argumentExpression) {
- // Example: we generate SAM constructor call Comparator(f), where f: (Int, Int) -> Int
-
+ public JvmClassName genWrapper(@NotNull JetFile file) {
// Name for generated class, in form of whatever$1
- JvmClassName name = bindingContext.get(CodegenBinding.FQN_FOR_SAM_CONSTRUCTOR, callExpression);
- assert name != null : "internal class name not found for " + callExpression.getText();
+ JvmClassName name = JvmClassName.byInternalName(getWrapperName(file));
- // e.g. (Int, Int) -> Int
- JetType functionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, argumentExpression);
- assert functionType != null && KotlinBuiltIns.getInstance().isFunctionType(functionType) :
- "not a function type of " + argumentExpression.getText() + ": " + functionType;
+ // e.g. (T, T) -> Int
+ JetType functionType = samInterface.getFunctionTypeForSamInterface();
+ assert functionType != null : samInterface.toString();
+ // e.g. compare(T, T)
+ SimpleFunctionDescriptor interfaceFunction = SingleAbstractMethodUtils.getAbstractMethodOfSamInterface(samInterface);
- // SAM constructor call
- ResolvedCall extends CallableDescriptor> resolvedCall =
- bindingContext.get(BindingContext.RESOLVED_CALL, callExpression.getCalleeExpression());
- assert resolvedCall != null : "couldn't find resolved call for " + callExpression.getText();
-
- // e.g. Comparator
- JetType resultType = resolvedCall.getResultingDescriptor().getReturnType();
- assert resultType != null && resultType.getConstructor() == samInterface.getTypeConstructor() :
- "unexpected result type: " + resultType;
-
- // e.g. compare(Int, Int)
- SimpleFunctionDescriptor interfaceFunction = SingleAbstractMethodUtils.getAbstractMethodOfSamType(resultType);
-
- ClassBuilder cv = state.getFactory().newVisitor(name.getInternalName(), callExpression.getContainingFile());
- cv.defineClass(callExpression,
+ ClassBuilder cv = state.getFactory().newVisitor(name.getInternalName(), file);
+ cv.defineClass(file,
V1_6,
ACC_FINAL,
name.getInternalName(),
@@ -88,7 +72,7 @@ public class SamWrapperCodegen extends GenerationStateAware {
OBJECT_TYPE.getInternalName(),
new String[]{JvmClassName.byClassDescriptor(samInterface).getInternalName()}
);
- cv.visitSource(callExpression.getContainingFile().getName(), null);
+ cv.visitSource(file.getName(), null);
// e.g. ASM type for Function2
Type functionAsmType = state.getTypeMapper().mapType(functionType, JetTypeMapperMode.VALUE);
@@ -148,4 +132,14 @@ public class SamWrapperCodegen extends GenerationStateAware {
StackValue functionField = StackValue.field(functionType, JvmClassName.byType(ownerType), FUNCTION_FIELD_NAME, false);
codegen.genDelegate(interfaceFunction, invokeFunction, functionField);
}
+
+ private String getWrapperName(@NotNull JetFile containingFile) {
+ NamespaceDescriptor namespace = state.getBindingContext().get(BindingContext.FILE_TO_NAMESPACE, containingFile);
+ assert namespace != null : "couldn't find namespace for file: " + containingFile.getVirtualFile();
+ FqName fqName = DescriptorUtils.getFQName(namespace).toSafe();
+ String packageInternalName = JvmClassName.byFqNameWithoutInnerClasses(
+ PackageClassUtils.getPackageClassFqName(fqName)).getInternalName();
+ return packageInternalName + "$sam$" + samInterface.getName().asString() + "$" +
+ Integer.toHexString(CodegenUtil.getPathHashCode(containingFile) * 31 + DescriptorUtils.getFQName(samInterface).hashCode());
+ }
}
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ScriptCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ScriptCodegen.java
index 5861fa2a645..8d18cb286b1 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/ScriptCodegen.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/ScriptCodegen.java
@@ -24,6 +24,7 @@ import org.jetbrains.asm4.Type;
import org.jetbrains.asm4.commons.InstructionAdapter;
import org.jetbrains.asm4.commons.Method;
import org.jetbrains.jet.codegen.context.CodegenContext;
+import org.jetbrains.jet.codegen.context.FieldOwnerContext;
import org.jetbrains.jet.codegen.context.MethodContext;
import org.jetbrains.jet.codegen.context.ScriptContext;
import org.jetbrains.jet.codegen.signature.JvmMethodSignature;
@@ -53,7 +54,7 @@ public class ScriptCodegen extends MemberCodegen {
private Method scriptConstructorMethod;
public ScriptCodegen(@NotNull GenerationState state) {
- super(state);
+ super(state, null);
}
@Inject
@@ -145,7 +146,6 @@ public class ScriptCodegen extends MemberCodegen {
ImplementationBodyCodegen.generateInitializers(
new ExpressionCodegen(instructionAdapter, frameMap, Type.VOID_TYPE, context, state),
- instructionAdapter,
scriptDeclaration.getDeclarations(),
bindingContext,
state);
@@ -197,7 +197,7 @@ public class ScriptCodegen extends MemberCodegen {
}
}
- private void genMembers(@NotNull JetScript scriptDeclaration, @NotNull CodegenContext context, @NotNull ClassBuilder classBuilder) {
+ private void genMembers(@NotNull JetScript scriptDeclaration, @NotNull FieldOwnerContext context, @NotNull ClassBuilder classBuilder) {
for (JetDeclaration decl : scriptDeclaration.getDeclarations()) {
genFunctionOrProperty(context, (JetTypeParameterListOwner) decl, classBuilder);
}
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java b/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java
index b7f8d673b7d..89b63089c40 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java
@@ -30,7 +30,6 @@ import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
-import org.jetbrains.jet.lang.resolve.java.JvmAbi;
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue;
@@ -116,10 +115,12 @@ public abstract class StackValue {
return new Invert(stackValue);
}
+ @NotNull
public static StackValue arrayElement(Type type, boolean unbox) {
return new ArrayElement(type, unbox);
}
+ @NotNull
public static StackValue collectionElement(
Type type,
ResolvedCall getter,
@@ -131,23 +132,25 @@ public abstract class StackValue {
}
@NotNull
- public static StackValue field(@NotNull Type type, @NotNull JvmClassName owner, @NotNull String name, boolean isStatic) {
+ public static Field field(@NotNull Type type, @NotNull JvmClassName owner, @NotNull String name, boolean isStatic) {
return new Field(type, owner, name, isStatic);
}
+ @NotNull
public static Property property(
- PropertyDescriptor descriptor,
- JvmClassName methodOwner,
- Type type,
+ @NotNull PropertyDescriptor descriptor,
+ @NotNull JvmClassName methodOwner,
+ @NotNull Type type,
boolean isStatic,
- boolean isDelegated,
+ @NotNull String name,
@Nullable CallableMethod getter,
@Nullable CallableMethod setter,
GenerationState state
) {
- return new Property(descriptor, methodOwner, getter, setter, isStatic, isDelegated, type, state);
+ return new Property(descriptor, methodOwner, getter, setter, isStatic, name, type, state);
}
+ @NotNull
public static StackValue expression(Type type, JetExpression expression, ExpressionCodegen generator) {
return new Expression(type, expression, generator);
}
@@ -207,15 +210,6 @@ public abstract class StackValue {
}
}
- private static void pop(Type type, InstructionAdapter v) {
- if (type.getSize() == 1) {
- v.pop();
- }
- else {
- v.pop2();
- }
- }
-
protected void coerceTo(Type toType, InstructionAdapter v) {
coerce(this.type, toType, v);
}
@@ -228,7 +222,7 @@ public abstract class StackValue {
if (toType.equals(fromType)) return;
if (toType.getSort() == Type.VOID) {
- pop(fromType, v);
+ pop(v, fromType);
}
else if (fromType.getSort() == Type.VOID) {
if (toType.equals(JET_UNIT_TYPE) || toType.equals(OBJECT_TYPE)) {
@@ -242,7 +236,7 @@ public abstract class StackValue {
}
}
else if (toType.equals(JET_UNIT_TYPE)) {
- pop(fromType, v);
+ pop(v, fromType);
putUnitInstance(v);
}
else if (toType.getSort() == Type.ARRAY) {
@@ -338,7 +332,7 @@ public abstract class StackValue {
return receiverWithParameter;
}
- public static StackValue singleton(ClassDescriptor classDescriptor, JetTypeMapper typeMapper) {
+ public static Field singleton(ClassDescriptor classDescriptor, JetTypeMapper typeMapper) {
FieldInfo info = FieldInfo.createForSingleton(classDescriptor, typeMapper);
return field(info.getFieldType(), JvmClassName.byInternalName(info.getOwnerInternalName()), info.getFieldName(), true);
}
@@ -642,7 +636,7 @@ public abstract class StackValue {
method.invokeWithNotNullAssertion(v, state, resolvedSetCall);
Type returnType = asmMethod.getReturnType();
if (returnType != Type.VOID_TYPE) {
- pop(returnType, v);
+ pop(v, returnType);
}
}
else {
@@ -870,12 +864,13 @@ public abstract class StackValue {
private final PropertyDescriptor descriptor;
@NotNull
private final GenerationState state;
- private final boolean isDelegated;
+
+ private final String name;
public Property(
@NotNull PropertyDescriptor descriptor, @NotNull JvmClassName methodOwner,
@Nullable CallableMethod getter, @Nullable CallableMethod setter, boolean isStatic,
- boolean isDelegated, @NotNull Type type, @NotNull GenerationState state
+ @NotNull String name, @NotNull Type type, @NotNull GenerationState state
) {
super(type, isStatic);
this.methodOwner = methodOwner;
@@ -883,7 +878,7 @@ public abstract class StackValue {
this.setter = setter;
this.descriptor = descriptor;
this.state = state;
- this.isDelegated = isDelegated;
+ this.name = name;
}
@Override
@@ -913,7 +908,7 @@ public abstract class StackValue {
}
private String getPropertyName() {
- return isDelegated ? JvmAbi.getPropertyDelegateName(descriptor.getName()) : descriptor.getName().asString();
+ return name;
}
}
@@ -1244,7 +1239,7 @@ public abstract class StackValue {
}
}
- private abstract static class StackValueWithSimpleReceiver extends StackValue {
+ public abstract static class StackValueWithSimpleReceiver extends StackValue {
protected final boolean isStatic;
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/TraitImplBodyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/TraitImplBodyCodegen.java
index 47042069858..1f04bcc9c5d 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/TraitImplBodyCodegen.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/TraitImplBodyCodegen.java
@@ -16,7 +16,7 @@
package org.jetbrains.jet.codegen;
-import org.jetbrains.jet.codegen.context.CodegenContext;
+import org.jetbrains.jet.codegen.context.ClassContext;
import org.jetbrains.jet.codegen.state.GenerationState;
import org.jetbrains.jet.codegen.state.JetTypeMapperMode;
import org.jetbrains.jet.lang.psi.JetClassOrObject;
@@ -24,8 +24,8 @@ import org.jetbrains.jet.lang.psi.JetClassOrObject;
import static org.jetbrains.asm4.Opcodes.*;
public class TraitImplBodyCodegen extends ClassBodyCodegen {
- public TraitImplBodyCodegen(JetClassOrObject aClass, CodegenContext context, ClassBuilder v, GenerationState state) {
- super(aClass, context, v, state);
+ public TraitImplBodyCodegen(JetClassOrObject aClass, ClassContext context, ClassBuilder v, GenerationState state) {
+ super(aClass, context, v, state, null);
}
@Override
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/binding/CodegenAnnotatingVisitor.java b/compiler/backend/src/org/jetbrains/jet/codegen/binding/CodegenAnnotatingVisitor.java
index b91bf08e7d7..05c36469dfa 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/binding/CodegenAnnotatingVisitor.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/binding/CodegenAnnotatingVisitor.java
@@ -16,9 +16,13 @@
package org.jetbrains.jet.codegen.binding;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.tree.IElementType;
+import com.intellij.psi.tree.TokenSet;
import com.intellij.util.containers.Stack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.jet.codegen.SamCodegenUtil;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.descriptors.impl.ClassDescriptorImpl;
@@ -26,10 +30,14 @@ import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.BindingTrace;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
+import org.jetbrains.jet.lang.resolve.calls.model.ExpressionValueArgument;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
+import org.jetbrains.jet.lang.resolve.calls.model.ResolvedValueArgument;
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
+import org.jetbrains.jet.lang.resolve.java.descriptor.ClassDescriptorFromJvmBytecode;
+import org.jetbrains.jet.lang.resolve.java.sam.SingleAbstractMethodUtils;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
@@ -37,14 +45,19 @@ import org.jetbrains.jet.lang.types.JetType;
import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import static org.jetbrains.jet.codegen.CodegenUtil.peekFromStack;
import static org.jetbrains.jet.codegen.FunctionTypesUtil.getSuperTypeForClosure;
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
+import static org.jetbrains.jet.lexer.JetTokens.*;
class CodegenAnnotatingVisitor extends JetVisitorVoid {
+ private static final TokenSet BINARY_OPERATIONS = TokenSet.orSet(
+ AUGMENTED_ASSIGNMENTS, TokenSet.create(PLUS, MINUS, MUL, DIV, PERC, RANGE, LT, GT, LTEQ, GTEQ, IDENTIFIER));
+
private final Map anonymousSubclassesCount = new HashMap();
private final Stack classStack = new Stack();
@@ -57,30 +70,6 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
this.bindingContext = bindingTrace.getBindingContext();
}
- @Override
- public void visitCallExpression(JetCallExpression expression) {
- super.visitCallExpression(expression);
-
- JetExpression callee = expression.getCalleeExpression();
- assert callee != null : "not found callee for " + expression.getText();
-
- ResolvedCall extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, callee);
- if (resolvedCall == null) {
- return;
- }
-
- DeclarationDescriptor funDescriptor = resolvedCall.getResultingDescriptor();
-
- if (funDescriptor instanceof SimpleFunctionDescriptor) {
- ClassDescriptor samTrait = bindingContext.get(
- BindingContext.SAM_CONSTRUCTOR_TO_INTERFACE, ((SimpleFunctionDescriptor) funDescriptor).getOriginal());
- if (samTrait != null) {
- String name = inventAnonymousClassName(expression);
- bindingTrace.record(FQN_FOR_SAM_CONSTRUCTOR, expression, JvmClassName.byInternalName(name));
- }
- }
- }
-
@NotNull
private ClassDescriptor recordClassForFunction(@NotNull FunctionDescriptor funDescriptor, @NotNull JetType superType) {
ClassDescriptor classDescriptor;
@@ -116,12 +105,11 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
if (declaration instanceof JetFunctionLiteralExpression ||
declaration instanceof JetNamedFunction ||
declaration instanceof JetObjectLiteralExpression ||
- declaration instanceof JetCallExpression ||
declaration instanceof JetCallableReferenceExpression) {
}
else {
throw new IllegalStateException(
- "Class-less declaration which is not JetFunctionLiteralExpression|JetNamedFunction|JetObjectLiteralExpression|JetCallExpression|JetCallableReferenceExpression : " +
+ "Class-less declaration which is not JetFunctionLiteralExpression|JetNamedFunction|JetObjectLiteralExpression|JetCallableReferenceExpression : " +
declaration.getClass().getName());
}
}
@@ -364,4 +352,110 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
return null;
}
}
+
+ @Override
+ public void visitCallExpression(JetCallExpression expression) {
+ super.visitCallExpression(expression);
+ ResolvedCall extends CallableDescriptor> call = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getCalleeExpression());
+ if (call == null) {
+ return;
+ }
+
+ CallableDescriptor descriptor = call.getResultingDescriptor();
+ if (!(descriptor instanceof FunctionDescriptor)) {
+ return;
+ }
+ FunctionDescriptor original = SamCodegenUtil.getOriginalIfSamAdapter(bindingContext, descriptor);
+
+ if (original == null) {
+ return;
+ }
+ List valueArguments = call.getValueArgumentsByIndex();
+ for (ValueParameterDescriptor valueParameter : original.getValueParameters()) {
+ ClassDescriptorFromJvmBytecode samInterface = getInterfaceIfSamType(valueParameter.getType());
+ if (samInterface == null) {
+ continue;
+ }
+
+ ResolvedValueArgument resolvedValueArgument = valueArguments.get(valueParameter.getIndex());
+ assert resolvedValueArgument instanceof ExpressionValueArgument : resolvedValueArgument;
+ ValueArgument valueArgument = ((ExpressionValueArgument) resolvedValueArgument).getValueArgument();
+ assert valueArgument != null;
+ JetExpression argumentExpression = valueArgument.getArgumentExpression();
+ assert argumentExpression != null : valueArgument.asElement().getText();
+
+ bindingTrace.record(CodegenBinding.SAM_VALUE, argumentExpression, samInterface);
+ }
+ }
+
+ @Override
+ public void visitBinaryExpression(JetBinaryExpression expression) {
+ super.visitBinaryExpression(expression);
+
+ FunctionDescriptor operationDescriptor =
+ (FunctionDescriptor) bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference());
+ if (operationDescriptor == null) return;
+
+ FunctionDescriptor original = SamCodegenUtil.getOriginalIfSamAdapter(bindingContext, operationDescriptor);
+ if (original == null) return;
+
+ ClassDescriptorFromJvmBytecode samInterfaceOfParameter = getInterfaceIfSamType(original.getValueParameters().get(0).getType());
+ if (samInterfaceOfParameter == null) return;
+
+ IElementType token = expression.getOperationToken();
+ if (BINARY_OPERATIONS.contains(token)) {
+ bindingTrace.record(CodegenBinding.SAM_VALUE, expression.getRight(), samInterfaceOfParameter);
+ }
+ else if (token == IN_KEYWORD || token == NOT_IN) {
+ bindingTrace.record(CodegenBinding.SAM_VALUE, expression.getLeft(), samInterfaceOfParameter);
+ }
+ }
+
+ @Override
+ public void visitArrayAccessExpression(JetArrayAccessExpression expression) {
+ super.visitArrayAccessExpression(expression);
+
+ FunctionDescriptor operationDescriptor = (FunctionDescriptor) bindingContext.get(BindingContext.REFERENCE_TARGET, expression);
+ if (operationDescriptor == null) {
+ return;
+ }
+
+ boolean isSetter = operationDescriptor.getName().asString().equals("set");
+ FunctionDescriptor original = SamCodegenUtil.getOriginalIfSamAdapter(bindingContext, operationDescriptor);
+ if (original == null) {
+ return;
+ }
+
+ List indexExpressions = expression.getIndexExpressions();
+ List parameters = original.getValueParameters();
+ for (ValueParameterDescriptor valueParameter : parameters) {
+ ClassDescriptorFromJvmBytecode samInterface = getInterfaceIfSamType(valueParameter.getType());
+ if (samInterface == null) {
+ continue;
+ }
+
+ if (isSetter && valueParameter.getIndex() == parameters.size() - 1) {
+ PsiElement parent = expression.getParent();
+ if (parent instanceof JetBinaryExpression && ((JetBinaryExpression) parent).getOperationToken() == EQ) {
+ JetExpression right = ((JetBinaryExpression) parent).getRight();
+ bindingTrace.record(CodegenBinding.SAM_VALUE, right, samInterface);
+ }
+ }
+ else {
+ JetExpression indexExpression = indexExpressions.get(valueParameter.getIndex());
+ bindingTrace.record(CodegenBinding.SAM_VALUE, indexExpression, samInterface);
+ }
+ }
+ }
+
+ @Nullable
+ private static ClassDescriptorFromJvmBytecode getInterfaceIfSamType(@NotNull JetType originalType) {
+ if (!SingleAbstractMethodUtils.isSamType(originalType)) {
+ return null;
+ }
+ ClassDescriptorFromJvmBytecode samInterface =
+ (ClassDescriptorFromJvmBytecode) originalType.getConstructor().getDeclarationDescriptor();
+ assert samInterface != null;
+ return samInterface;
+ }
}
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/binding/CodegenBinding.java b/compiler/backend/src/org/jetbrains/jet/codegen/binding/CodegenBinding.java
index 7ff090b7bfa..20b2f66c69a 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/binding/CodegenBinding.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/binding/CodegenBinding.java
@@ -28,6 +28,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.BindingTrace;
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
+import org.jetbrains.jet.lang.resolve.java.descriptor.ClassDescriptorFromJvmBytecode;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
@@ -51,14 +52,14 @@ public class CodegenBinding {
public static final WritableSlice FQN = Slices.createSimpleSlice();
- public static final WritableSlice FQN_FOR_SAM_CONSTRUCTOR = Slices.createSimpleSlice();
-
public static final WritableSlice SCRIPT_NAMES = Slices.createSimpleSetSlice();
public static final WritableSlice ENUM_ENTRY_CLASS_NEED_SUBCLASS = Slices.createSimpleSetSlice();
public static final WritableSlice> INNER_CLASSES = Slices.createSimpleSlice();
+ public static final WritableSlice SAM_VALUE = Slices.createSimpleSlice();
+
private CodegenBinding() {
}
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/context/AnonymousClassContext.java b/compiler/backend/src/org/jetbrains/jet/codegen/context/AnonymousClassContext.java
index f76eaf973ee..d3c5cbbb612 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/context/AnonymousClassContext.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/context/AnonymousClassContext.java
@@ -22,9 +22,8 @@ import org.jetbrains.jet.codegen.OwnerKind;
import org.jetbrains.jet.codegen.state.JetTypeMapper;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
-import static org.jetbrains.jet.codegen.binding.CodegenBinding.CLOSURE;
+public class AnonymousClassContext extends ClassContext {
-public class AnonymousClassContext extends CodegenContext {
public AnonymousClassContext(
@NotNull JetTypeMapper typeMapper,
@NotNull ClassDescriptor contextDescriptor,
@@ -33,14 +32,7 @@ public class AnonymousClassContext extends CodegenContext {
@Nullable LocalLookup localLookup
) {
//noinspection SuspiciousMethodCalls
- super(contextDescriptor, contextKind, parentContext, typeMapper.getBindingContext().get(CLOSURE, contextDescriptor),
- contextDescriptor, localLookup);
- initOuterExpression(typeMapper, contextDescriptor);
- }
-
- @Override
- public boolean isStatic() {
- return false;
+ super(typeMapper, contextDescriptor, contextKind, parentContext, localLookup);
}
@Override
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/context/ClassContext.java b/compiler/backend/src/org/jetbrains/jet/codegen/context/ClassContext.java
index 2dac8bb2e83..5116ca78745 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/context/ClassContext.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/context/ClassContext.java
@@ -24,7 +24,8 @@ import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import static org.jetbrains.jet.codegen.binding.CodegenBinding.CLOSURE;
-public class ClassContext extends CodegenContext {
+public class ClassContext extends FieldOwnerContext {
+
public ClassContext(
@NotNull JetTypeMapper typeMapper,
@NotNull ClassDescriptor contextDescriptor,
@@ -38,6 +39,15 @@ public class ClassContext extends CodegenContext {
initOuterExpression(typeMapper, contextDescriptor);
}
+
+ @Nullable
+ public CodegenContext getClassObjectContext() {
+ if (getContextDescriptor().getClassObjectDescriptor() != null) {
+ return findChildContext(getContextDescriptor().getClassObjectDescriptor());
+ }
+ return null;
+ }
+
@Override
public boolean isStatic() {
return false;
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/context/CodegenContext.java b/compiler/backend/src/org/jetbrains/jet/codegen/context/CodegenContext.java
index f78261f5c6c..aaef6ff3338 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/context/CodegenContext.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/context/CodegenContext.java
@@ -27,21 +27,25 @@ import org.jetbrains.jet.codegen.state.JetTypeMapper;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.descriptors.impl.ConstructorDescriptorImpl;
+import org.jetbrains.jet.lang.resolve.BindingContext;
+import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import static org.jetbrains.asm4.Opcodes.ACC_PRIVATE;
import static org.jetbrains.jet.codegen.AsmUtil.CAPTURED_THIS_FIELD;
+import static org.jetbrains.jet.codegen.AsmUtil.getVisibilityAccessFlag;
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.OBJECT_TYPE;
-public abstract class CodegenContext {
+public abstract class CodegenContext {
public static final CodegenContext STATIC = new RootContext();
@NotNull
- private final DeclarationDescriptor contextDescriptor;
+ private final T contextDescriptor;
@NotNull
private final OwnerKind contextKind;
@@ -52,13 +56,16 @@ public abstract class CodegenContext {
public final MutableClosure closure;
- HashMap accessors;
+ private HashMap accessors;
+
+ private Map childContexts;
protected StackValue outerExpression;
+
private final LocalLookup enclosingLocalLookup;
public CodegenContext(
- @NotNull DeclarationDescriptor contextDescriptor,
+ @NotNull T contextDescriptor,
@NotNull OwnerKind contextKind,
@Nullable CodegenContext parentContext,
@Nullable MutableClosure closure,
@@ -71,6 +78,10 @@ public abstract class CodegenContext {
this.closure = closure;
this.thisDescriptor = thisDescriptor;
this.enclosingLocalLookup = expressionCodegen;
+
+ if (parentContext != null) {
+ parentContext.addChild(this);
+ }
}
@NotNull
@@ -126,7 +137,7 @@ public abstract class CodegenContext {
}
@NotNull
- public DeclarationDescriptor getContextDescriptor() {
+ public T getContextDescriptor() {
return contextDescriptor;
}
@@ -135,31 +146,37 @@ public abstract class CodegenContext {
return contextKind;
}
- public CodegenContext intoNamespace(@NotNull NamespaceDescriptor descriptor) {
+ @NotNull
+ public FieldOwnerContext intoNamespace(@NotNull NamespaceDescriptor descriptor) {
return new NamespaceContext(descriptor, this, OwnerKind.NAMESPACE);
}
- public CodegenContext intoNamespacePart(String delegateTo, NamespaceDescriptor descriptor) {
+ @NotNull
+ public FieldOwnerContext intoNamespacePart(String delegateTo, NamespaceDescriptor descriptor) {
return new NamespaceContext(descriptor, this, new OwnerKind.StaticDelegateKind(delegateTo));
}
- public CodegenContext intoClass(ClassDescriptor descriptor, OwnerKind kind, GenerationState state) {
+ @NotNull
+ public ClassContext intoClass(ClassDescriptor descriptor, OwnerKind kind, GenerationState state) {
return new ClassContext(state.getTypeMapper(), descriptor, kind, this, null);
}
- public CodegenContext intoAnonymousClass(
- ClassDescriptor descriptor,
- ExpressionCodegen expressionCodegen
+ @NotNull
+ public ClassContext intoAnonymousClass(
+ @NotNull ClassDescriptor descriptor,
+ @NotNull ExpressionCodegen expressionCodegen
) {
JetTypeMapper typeMapper = expressionCodegen.getState().getTypeMapper();
return new AnonymousClassContext(typeMapper, descriptor, OwnerKind.IMPLEMENTATION, this,
expressionCodegen);
}
+ @NotNull
public MethodContext intoFunction(FunctionDescriptor descriptor) {
return new MethodContext(descriptor, getContextKind(), this);
}
+ @NotNull
public ConstructorContext intoConstructor(ConstructorDescriptor descriptor) {
if (descriptor == null) {
descriptor = new ConstructorDescriptorImpl(getThisDescriptor(), Collections.emptyList(), true)
@@ -169,6 +186,7 @@ public abstract class CodegenContext {
return new ConstructorContext(descriptor, getContextKind(), this);
}
+ @NotNull
public CodegenContext intoScript(@NotNull ScriptDescriptor script, @NotNull ClassDescriptor classDescriptor) {
return new ScriptContext(script, classDescriptor, OwnerKind.IMPLEMENTATION, this, closure);
}
@@ -297,4 +315,110 @@ public abstract class CodegenContext {
public Map getAccessors() {
return accessors == null ? Collections.emptyMap() : accessors;
}
+
+ @NotNull
+ public PropertyDescriptor accessiblePropertyDescriptor(PropertyDescriptor propertyDescriptor) {
+ return (PropertyDescriptor) accessibleDescriptorIfNeeded(propertyDescriptor, true);
+ }
+
+ @NotNull
+ public FunctionDescriptor accessibleFunctionDescriptor(FunctionDescriptor fd) {
+ return (FunctionDescriptor) accessibleDescriptorIfNeeded(fd, true);
+ }
+
+ @NotNull
+ public void recordSyntheticAccessorIfNeeded(@NotNull FunctionDescriptor fd, @NotNull JetTypeMapper typeMapper) {
+ if (fd instanceof ConstructorDescriptor || needSyntheticAccessorInBindingTrace(fd, typeMapper)) {
+ accessibleDescriptorIfNeeded(fd, false);
+ }
+ }
+
+ @NotNull
+ public void recordSyntheticAccessorIfNeeded(PropertyDescriptor propertyDescriptor, JetTypeMapper typeMapper) {
+ if (needSyntheticAccessorInBindingTrace(propertyDescriptor, typeMapper)) {
+ accessibleDescriptorIfNeeded(propertyDescriptor, false);
+ }
+ }
+
+ private boolean needSyntheticAccessorInBindingTrace(@NotNull CallableMemberDescriptor descriptor, @NotNull JetTypeMapper typeMapper) {
+ Boolean result = typeMapper.getBindingContext().get(BindingContext.NEED_SYNTHETIC_ACCESSOR, descriptor);
+ return result == null ? false : result.booleanValue();
+ }
+
+ @NotNull
+ private int getAccessFlags(CallableMemberDescriptor descriptor) {
+ int flag = getVisibilityAccessFlag(descriptor);
+ if (descriptor instanceof PropertyDescriptor) {
+ PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
+
+ PropertySetterDescriptor setter = propertyDescriptor.getSetter();
+ PropertyGetterDescriptor getter = propertyDescriptor.getGetter();
+
+ flag |= (getter == null ? 0 : getVisibilityAccessFlag(getter)) |
+ (setter == null ? 0 : getVisibilityAccessFlag(setter));
+ }
+ return flag;
+ }
+
+ @NotNull
+ private MemberDescriptor accessibleDescriptorIfNeeded(CallableMemberDescriptor descriptor, boolean fromOutsideContext) {
+ int flag = getAccessFlags(descriptor);
+ if ((flag & ACC_PRIVATE) == 0) {
+ return descriptor;
+ }
+
+ CodegenContext descriptorContext = null;
+ if (!fromOutsideContext || getClassOrNamespaceDescriptor() != descriptor.getContainingDeclaration()) {
+ DeclarationDescriptor enclosed = descriptor.getContainingDeclaration();
+ boolean isClassObjectMember = DescriptorUtils.isClassObject(enclosed);
+ //go upper
+ if (hasThisDescriptor() && (enclosed != getThisDescriptor() || !fromOutsideContext)) {
+ CodegenContext currentContext = this;
+ while (currentContext != null) {
+ if (currentContext.getContextDescriptor() == enclosed) {
+ descriptorContext = currentContext;
+ break;
+ }
+
+ //accessors for private members in class object for call from class
+ if (isClassObjectMember && currentContext instanceof ClassContext) {
+ ClassContext classContext = (ClassContext) currentContext;
+ CodegenContext classObject = classContext.getClassObjectContext();
+ if (classObject != null && classObject.getContextDescriptor() == enclosed) {
+ descriptorContext = classObject;
+ break;
+ }
+ }
+
+ currentContext = currentContext.getParentContext();
+ }
+ }
+ }
+
+ return (MemberDescriptor) (descriptorContext != null ? descriptorContext.getAccessor(descriptor) : descriptor);
+ }
+
+ private void addChild(@NotNull CodegenContext child) {
+ if (shouldAddChild(child)) {
+ if (childContexts == null) {
+ childContexts = new HashMap();
+ }
+ DeclarationDescriptor childContextDescriptor = child.getContextDescriptor();
+ childContexts.put(childContextDescriptor, child);
+ }
+ }
+
+ protected boolean shouldAddChild(@NotNull CodegenContext child) {
+ DeclarationDescriptor childContextDescriptor = child.contextDescriptor;
+ if (childContextDescriptor instanceof ClassDescriptor) {
+ ClassKind kind = ((ClassDescriptor) childContextDescriptor).getKind();
+ return kind == ClassKind.CLASS_OBJECT;
+ }
+ return false;
+ }
+
+ @Nullable
+ public CodegenContext findChildContext(@NotNull DeclarationDescriptor child) {
+ return childContexts == null ? null : childContexts.get(child);
+ }
}
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/context/FieldOwnerContext.java b/compiler/backend/src/org/jetbrains/jet/codegen/context/FieldOwnerContext.java
new file mode 100644
index 00000000000..ece881dda9e
--- /dev/null
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/context/FieldOwnerContext.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.codegen.context;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.jet.codegen.OwnerKind;
+import org.jetbrains.jet.codegen.binding.MutableClosure;
+import org.jetbrains.jet.lang.descriptors.*;
+import org.jetbrains.jet.lang.resolve.java.JvmAbi;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract class FieldOwnerContext extends CodegenContext {
+
+ //default property name -> map bytecode name>
+ private Map> fieldNames = new HashMap>();
+
+ public FieldOwnerContext(
+ @NotNull T contextDescriptor,
+ @NotNull OwnerKind contextKind,
+ @Nullable CodegenContext parentContext,
+ @Nullable MutableClosure closure,
+ @Nullable ClassDescriptor thisDescriptor,
+ @Nullable LocalLookup expressionCodegen
+ ) {
+ super(contextDescriptor, contextKind, parentContext, closure, thisDescriptor, expressionCodegen);
+ }
+
+ public String getFieldName(PropertyDescriptor descriptor) {
+ return getFieldName(descriptor, false);
+ }
+
+ public String getFieldName(PropertyDescriptor descriptor, boolean isDelegated) {
+ assert descriptor.getKind() != CallableMemberDescriptor.Kind.FAKE_OVERRIDE;
+ boolean isExtension = descriptor.getReceiverParameter() != null;
+
+ return getFieldName(descriptor, isDelegated, isExtension);
+ }
+
+ private String getFieldName(PropertyDescriptor descriptor, boolean isDelegated, boolean isExtension) {
+ descriptor = descriptor.getOriginal();
+ String defaultPropertyName = JvmAbi.getDefaultPropertyName(descriptor.getName(), isDelegated, isExtension);
+
+ Map descriptor2Name = fieldNames.get(defaultPropertyName);
+ if (descriptor2Name == null) {
+ descriptor2Name = new HashMap();
+ fieldNames.put(defaultPropertyName, descriptor2Name);
+ }
+
+ String actualName = descriptor2Name.get(descriptor);
+ if (actualName == null) {
+ actualName = descriptor2Name.isEmpty() ? defaultPropertyName : defaultPropertyName + "$" + descriptor2Name.size();
+ descriptor2Name.put(descriptor, actualName);
+ }
+ return actualName;
+ }
+}
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/context/NamespaceContext.java b/compiler/backend/src/org/jetbrains/jet/codegen/context/NamespaceContext.java
index cf4e893f093..f492af72ae5 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/context/NamespaceContext.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/context/NamespaceContext.java
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.codegen.OwnerKind;
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
-public class NamespaceContext extends CodegenContext {
+public class NamespaceContext extends FieldOwnerContext {
public NamespaceContext(@NotNull NamespaceDescriptor contextDescriptor, @Nullable CodegenContext parent, @NotNull OwnerKind kind) {
super(contextDescriptor, kind, parent, null, null, null);
}
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/context/ScriptContext.java b/compiler/backend/src/org/jetbrains/jet/codegen/context/ScriptContext.java
index 18ad481bf9b..e88efbf9556 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/context/ScriptContext.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/context/ScriptContext.java
@@ -23,7 +23,7 @@ import org.jetbrains.jet.codegen.binding.MutableClosure;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.ScriptDescriptor;
-public class ScriptContext extends CodegenContext {
+public class ScriptContext extends FieldOwnerContext {
@NotNull
private final ScriptDescriptor scriptDescriptor;
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Increment.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Increment.java
index 89ecc7e31c5..f358295e8ef 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Increment.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Increment.java
@@ -29,7 +29,8 @@ import org.jetbrains.jet.lang.psi.JetReferenceExpression;
import java.util.List;
-import static org.jetbrains.jet.codegen.AsmUtil.*;
+import static org.jetbrains.jet.codegen.AsmUtil.genIncrement;
+import static org.jetbrains.jet.codegen.AsmUtil.unboxType;
public class Increment implements IntrinsicMethod {
private final int myDelta;
@@ -57,9 +58,9 @@ public class Increment implements IntrinsicMethod {
while (operand instanceof JetParenthesizedExpression) {
operand = ((JetParenthesizedExpression) operand).getExpression();
}
- if (operand instanceof JetReferenceExpression) {
+ if (operand instanceof JetReferenceExpression && expectedType == Type.INT_TYPE) {
int index = codegen.indexOfLocal((JetReferenceExpression) operand);
- if (index >= 0 && isIntPrimitive(expectedType)) {
+ if (index >= 0) {
return StackValue.preIncrement(index, myDelta);
}
}
@@ -68,12 +69,13 @@ public class Increment implements IntrinsicMethod {
value.dupReceiver(v);
value.put(expectedType, v);
- value.store(genIncrement(expectedType, myDelta, v), v);
+ genIncrement(expectedType, myDelta, v);
+ value.store(expectedType, v);
value.put(expectedType, v);
}
else {
receiver.put(expectedType, v);
- StackValue.coerce(genIncrement(expectedType, myDelta, v), expectedType, v);
+ genIncrement(expectedType, myDelta, v);
}
return StackValue.onStack(expectedType);
}
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/signature/BothSignatureWriter.java b/compiler/backend/src/org/jetbrains/jet/codegen/signature/BothSignatureWriter.java
index de3de631c4e..1b76b16aa17 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/signature/BothSignatureWriter.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/signature/BothSignatureWriter.java
@@ -43,7 +43,8 @@ public class BothSignatureWriter {
public enum Mode {
METHOD(CheckSignatureAdapter.METHOD_SIGNATURE),
- CLASS(CheckSignatureAdapter.CLASS_SIGNATURE),;
+ CLASS(CheckSignatureAdapter.CLASS_SIGNATURE),
+ TYPE(CheckSignatureAdapter.TYPE_SIGNATURE);
private final int asmType;
@@ -61,6 +62,9 @@ public class BothSignatureWriter {
RETURN_TYPE,
METHOD_END,
+ FIELD,
+ FIELD_END,
+
SUPERS,
CLASS_END,
}
@@ -341,6 +345,16 @@ public class BothSignatureWriter {
checkState(State.PARAMETERS);
}
+ public void writeFieldTypeStart() {
+ transitionState(State.START, State.FIELD);
+ jetSignatureWriter = new JetSignatureWriter();
+ }
+
+ public void writeFieldTypeEnd() {
+ jetSignatureWriter = null;
+ transitionState(State.FIELD, State.FIELD_END);
+ }
+
public void writeParameterType(JvmMethodParameterKind parameterKind) {
transitionState(State.PARAMETERS, State.PARAMETER);
@@ -486,7 +500,7 @@ public class BothSignatureWriter {
@Nullable
public String makeJavaGenericSignature() {
- if (state != State.METHOD_END && state != State.CLASS_END) {
+ if (state != State.METHOD_END && state != State.CLASS_END && state != State.FIELD_END) {
throw new IllegalStateException();
}
checkTopLevel();
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/state/GenerationState.java b/compiler/backend/src/org/jetbrains/jet/codegen/state/GenerationState.java
index 1ae5760d4a5..671a889855a 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/state/GenerationState.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/state/GenerationState.java
@@ -56,6 +56,9 @@ public class GenerationState {
@NotNull
private final IntrinsicMethods intrinsics;
+ @NotNull
+ private final SamWrapperClasses samWrapperClasses = new SamWrapperClasses(this);
+
@NotNull
private final BindingTrace bindingTrace;
@@ -154,6 +157,11 @@ public class GenerationState {
return intrinsics;
}
+ @NotNull
+ public SamWrapperClasses getSamWrapperClasses() {
+ return samWrapperClasses;
+ }
+
public boolean isGenerateNotNullAssertions() {
return generateNotNullAssertions;
}
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/state/JetTypeMapper.java b/compiler/backend/src/org/jetbrains/jet/codegen/state/JetTypeMapper.java
index d9606affaf0..cb1dbc1145a 100644
--- a/compiler/backend/src/org/jetbrains/jet/codegen/state/JetTypeMapper.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/state/JetTypeMapper.java
@@ -28,6 +28,7 @@ import org.jetbrains.jet.codegen.context.EnclosedValueDescriptor;
import org.jetbrains.jet.codegen.signature.*;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.JetDelegatorToSuperCall;
+import org.jetbrains.jet.lang.psi.JetExpression;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
@@ -635,6 +636,15 @@ public class JetTypeMapper extends BindingTraceAware {
return signatureVisitor.makeJvmMethodSignature(methodName);
}
+ @Nullable
+ public String mapFieldSignature(@NotNull JetType backingFieldType) {
+ BothSignatureWriter signatureVisitor = new BothSignatureWriter(BothSignatureWriter.Mode.TYPE, true);
+ signatureVisitor.writeFieldTypeStart();
+ mapType(backingFieldType, signatureVisitor, JetTypeMapperMode.VALUE);
+ signatureVisitor.writeFieldTypeEnd();
+ return signatureVisitor.makeJavaGenericSignature();
+ }
+
private void writeThisIfNeeded(
@NotNull CallableMemberDescriptor descriptor,
@NotNull OwnerKind kind,
@@ -961,4 +971,15 @@ public class JetTypeMapper extends BindingTraceAware {
}
return new CallableMethod(owner, null, null, descriptor, INVOKEINTERFACE, owner, receiverParameterType, owner.getAsmType());
}
+
+ @NotNull
+ public Type expressionType(JetExpression expr) {
+ JetType type = bindingContext.get(BindingContext.EXPRESSION_TYPE, expr);
+ return asmTypeOrVoid(type);
+ }
+
+ @NotNull
+ private Type asmTypeOrVoid(@Nullable JetType type) {
+ return type == null ? Type.VOID_TYPE : mapType(type);
+ }
}
diff --git a/compiler/cli/src/org/jetbrains/jet/cli/common/messages/AnalyzerWithCompilerReport.java b/compiler/cli/src/org/jetbrains/jet/cli/common/messages/AnalyzerWithCompilerReport.java
index 6e6092088cd..6ec5b9678bd 100644
--- a/compiler/cli/src/org/jetbrains/jet/cli/common/messages/AnalyzerWithCompilerReport.java
+++ b/compiler/cli/src/org/jetbrains/jet/cli/common/messages/AnalyzerWithCompilerReport.java
@@ -38,6 +38,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.java.AbiVersionUtil;
+import org.jetbrains.jet.lang.resolve.java.JavaBindingContext;
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
import java.util.Collection;
@@ -119,14 +120,14 @@ public final class AnalyzerWithCompilerReport {
private void reportAlternativeSignatureErrors() {
assert analyzeExhaust != null;
BindingContext bc = analyzeExhaust.getBindingContext();
- Collection descriptorsWithErrors = bc.getKeys(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS);
+ Collection descriptorsWithErrors = bc.getKeys(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS);
if (!descriptorsWithErrors.isEmpty()) {
StringBuilder message = new StringBuilder("The following Java entities have annotations with wrong Kotlin signatures:\n");
for (DeclarationDescriptor descriptor : descriptorsWithErrors) {
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(bc, descriptor);
assert declaration instanceof PsiModifierListOwner;
- List errors = bc.get(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, descriptor);
+ List errors = bc.get(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, descriptor);
assert errors != null && !errors.isEmpty();
String externalName = PsiFormatUtil.getExternalName((PsiModifierListOwner) declaration);
diff --git a/compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/CompileEnvironmentUtil.java b/compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/CompileEnvironmentUtil.java
index e8ccfee3774..da704f6a59f 100644
--- a/compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/CompileEnvironmentUtil.java
+++ b/compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/CompileEnvironmentUtil.java
@@ -21,7 +21,6 @@ import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.util.Function;
-import com.intellij.util.Processor;
import com.intellij.util.containers.ContainerUtil;
import jet.modules.AllModules;
import jet.modules.Module;
@@ -69,22 +68,9 @@ public class CompileEnvironmentUtil {
}
@Nullable
- public static File getUnpackedRuntimePath() {
- URL url = KotlinToJVMBytecodeCompiler.class.getClassLoader().getResource("jet/JetObject.class");
- if (url != null && url.getProtocol().equals("file")) {
- return new File(url.getPath()).getParentFile().getParentFile();
- }
- return null;
- }
-
- @Nullable
- public static File getRuntimeJarPath() {
- URL url = KotlinToJVMBytecodeCompiler.class.getClassLoader().getResource("jet/JetObject.class");
- if (url != null && url.getProtocol().equals("jar")) {
- String path = url.getPath();
- return new File(path.substring(path.indexOf(":") + 1, path.indexOf("!/")));
- }
- return null;
+ private static File getRuntimeJarPath() {
+ File runtimePath = PathUtil.getKotlinPathsForCompiler().getRuntimePath();
+ return runtimePath.exists() ? runtimePath : null;
}
@NotNull
@@ -221,53 +207,27 @@ public class CompileEnvironmentUtil {
}
private static void writeRuntimeToJar(final JarOutputStream stream) throws IOException {
- final File unpackedRuntimePath = getUnpackedRuntimePath();
- if (unpackedRuntimePath != null) {
- FileUtil.processFilesRecursively(unpackedRuntimePath, new Processor() {
- @Override
- public boolean process(File file) {
- if (file.isDirectory()) return true;
- String relativePath = FileUtil.getRelativePath(unpackedRuntimePath, file);
- try {
- stream.putNextEntry(new JarEntry(FileUtil.toSystemIndependentName(relativePath)));
- FileInputStream fis = new FileInputStream(file);
- try {
- FileUtil.copy(fis, stream);
- }
- finally {
- fis.close();
- }
+ File runtimeJarPath = getRuntimeJarPath();
+ if (runtimeJarPath != null) {
+ JarInputStream jis = new JarInputStream(new FileInputStream(runtimeJarPath));
+ try {
+ while (true) {
+ JarEntry e = jis.getNextJarEntry();
+ if (e == null) {
+ break;
}
- catch (IOException e) {
- throw new RuntimeException(e);
+ if (FileUtilRt.extensionEquals(e.getName(), "class")) {
+ stream.putNextEntry(e);
+ FileUtil.copy(jis, stream);
}
- return true;
}
- });
+ }
+ finally {
+ jis.close();
+ }
}
else {
- File runtimeJarPath = getRuntimeJarPath();
- if (runtimeJarPath != null) {
- JarInputStream jis = new JarInputStream(new FileInputStream(runtimeJarPath));
- try {
- while (true) {
- JarEntry e = jis.getNextJarEntry();
- if (e == null) {
- break;
- }
- if (FileUtil.getExtension(e.getName()).equals("class")) {
- stream.putNextEntry(e);
- FileUtil.copy(jis, stream);
- }
- }
- }
- finally {
- jis.close();
- }
- }
- else {
- throw new CompileEnvironmentException("Couldn't find runtime library");
- }
+ throw new CompileEnvironmentException("Couldn't find runtime library");
}
}
diff --git a/compiler/frontend.java/src/org/jetbrains/jet/di/InjectorForTopDownAnalyzerForJvm.java b/compiler/frontend.java/src/org/jetbrains/jet/di/InjectorForTopDownAnalyzerForJvm.java
index f39ccfdc0bc..cc1d90358f5 100644
--- a/compiler/frontend.java/src/org/jetbrains/jet/di/InjectorForTopDownAnalyzerForJvm.java
+++ b/compiler/frontend.java/src/org/jetbrains/jet/di/InjectorForTopDownAnalyzerForJvm.java
@@ -22,6 +22,7 @@ import org.jetbrains.jet.lang.resolve.BodyResolver;
import org.jetbrains.jet.lang.resolve.ControlFlowAnalyzer;
import org.jetbrains.jet.lang.resolve.DeclarationsChecker;
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
+import org.jetbrains.jet.lang.resolve.calls.NeedSyntheticCallResolverExtension;
import com.intellij.openapi.project.Project;
import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters;
import org.jetbrains.jet.lang.resolve.BindingTrace;
@@ -73,6 +74,7 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
private ControlFlowAnalyzer controlFlowAnalyzer;
private DeclarationsChecker declarationsChecker;
private DescriptorResolver descriptorResolver;
+ private NeedSyntheticCallResolverExtension needSyntheticCallResolverExtension;
private final Project project;
private final TopDownAnalysisParameters topDownAnalysisParameters;
private final BindingTrace bindingTrace;
@@ -125,6 +127,7 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
this.controlFlowAnalyzer = new ControlFlowAnalyzer();
this.declarationsChecker = new DeclarationsChecker();
this.descriptorResolver = new DescriptorResolver();
+ this.needSyntheticCallResolverExtension = new NeedSyntheticCallResolverExtension();
this.project = project;
this.topDownAnalysisParameters = topDownAnalysisParameters;
this.bindingTrace = bindingTrace;
@@ -178,6 +181,7 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
this.topDownAnalysisContext.setTopDownAnalysisParameters(topDownAnalysisParameters);
+ this.bodyResolver.setAnnotationResolver(annotationResolver);
this.bodyResolver.setCallResolver(callResolver);
this.bodyResolver.setContext(topDownAnalysisContext);
this.bodyResolver.setControlFlowAnalyzer(controlFlowAnalyzer);
@@ -224,6 +228,7 @@ public class InjectorForTopDownAnalyzerForJvm implements InjectorForTopDownAnaly
callResolver.setArgumentTypeResolver(argumentTypeResolver);
callResolver.setCandidateResolver(candidateResolver);
callResolver.setExpressionTypingServices(expressionTypingServices);
+ callResolver.setExtension(needSyntheticCallResolverExtension);
callResolver.setTypeResolver(typeResolver);
argumentTypeResolver.setExpressionTypingServices(expressionTypingServices);
diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaBindingContext.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaBindingContext.java
index fb6c5b34da9..2531f7b141b 100644
--- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaBindingContext.java
+++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaBindingContext.java
@@ -16,11 +16,15 @@
package org.jetbrains.jet.lang.resolve.java;
-import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
+import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
+import org.jetbrains.jet.lang.resolve.java.descriptor.ClassDescriptorFromJvmBytecode;
+import org.jetbrains.jet.util.slicedmap.BasicWritableSlice;
import org.jetbrains.jet.util.slicedmap.Slices;
import org.jetbrains.jet.util.slicedmap.WritableSlice;
+import java.util.List;
+
/**
* @see BindingContext
*/
@@ -32,6 +36,14 @@ public class JavaBindingContext {
public static final WritableSlice JAVA_NAMESPACE_KIND =
Slices.createSimpleSlice();
+ public static final WritableSlice> LOAD_FROM_JAVA_SIGNATURE_ERRORS =
+ new BasicWritableSlice>(Slices.ONLY_REWRITE_TO_EQUAL, true);
+
+ public static final WritableSlice IS_DECLARED_IN_JAVA = Slices.createSimpleSlice();
+
+ public static final WritableSlice SAM_CONSTRUCTOR_TO_INTERFACE = Slices.createSimpleSlice();
+ public static final WritableSlice SAM_ADAPTER_FUNCTION_TO_ORIGINAL = Slices.createSimpleSlice();
+
private JavaBindingContext() {
}
}
diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JvmAbi.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JvmAbi.java
index aa592f4dd02..35e1e2c48cb 100644
--- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JvmAbi.java
+++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JvmAbi.java
@@ -17,6 +17,7 @@
package org.jetbrains.jet.lang.resolve.java;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.Name;
@@ -59,6 +60,20 @@ public class JvmAbi {
return name.asString() + DELEGATED_PROPERTY_NAME_POSTFIX;
}
+
+ public static String getDefaultPropertyName(Name propertyName, boolean isDelegated, boolean isExtensionProperty) {
+ if (isDelegated) {
+ return getPropertyDelegateName(propertyName);
+ }
+
+ String name = propertyName.asString();
+ if (isExtensionProperty) {
+ name += "$ext";
+ }
+ return name;
+
+ }
+
private JvmAbi() {
}
}
diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/provider/MembersCache.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/provider/MembersCache.java
index 7443865b3d0..ebc028a30c4 100644
--- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/provider/MembersCache.java
+++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/provider/MembersCache.java
@@ -18,10 +18,13 @@ package org.jetbrains.jet.lang.resolve.java.provider;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
+import com.intellij.openapi.util.Ref;
import com.intellij.psi.*;
+import com.intellij.psi.util.MethodSignature;
+import com.intellij.psi.util.MethodSignatureBackedByPsiMethod;
import com.intellij.psi.util.PsiFormatUtil;
+import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.resolve.java.*;
@@ -37,6 +40,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import static com.intellij.psi.util.MethodSignatureUtil.areSignaturesErasureEqual;
import static com.intellij.psi.util.PsiFormatUtilBase.*;
public final class MembersCache {
@@ -420,17 +424,23 @@ public final class MembersCache {
return null;
}
- List methods = Lists.newArrayList();
- for (PsiMethod method : psiClass.getAllMethods()) {
- if (!isObjectMethod(method) && method.hasModifierProperty(PsiModifier.ABSTRACT)) {
- methods.add(method);
+ return findOnlyAbstractMethod(psiClass);
+ }
- if (method.hasTypeParameters()) {
- return null;
- }
- }
+ @Nullable
+ private static PsiMethod findOnlyAbstractMethod(@NotNull PsiClass psiClass) {
+ PsiClassType classType = JavaPsiFacade.getElementFactory(psiClass.getProject()).createType(psiClass);
+
+ OnlyAbstractMethodFinder finder = new OnlyAbstractMethodFinder();
+ if (finder.find(classType)) {
+ return finder.getFoundMethod();
}
- return methods.size() == 1 ? methods.get(0) : null;
+ return null;
+ }
+
+ private static boolean isVarargMethod(@NotNull PsiMethod method) {
+ PsiParameter lastParameter = ArrayUtil.getLastElement(method.getParameterList().getParameters());
+ return lastParameter != null && lastParameter.getType() instanceof PsiEllipsisType;
}
private static abstract class RunOnce implements Runnable {
@@ -445,4 +455,53 @@ public final class MembersCache {
protected abstract void doRun();
}
+
+ private static class OnlyAbstractMethodFinder {
+ private MethodSignatureBackedByPsiMethod found;
+
+ private boolean find(@NotNull PsiClassType classType) {
+ PsiClassType.ClassResolveResult classResolveResult = classType.resolveGenerics();
+ PsiSubstitutor classSubstitutor = classResolveResult.getSubstitutor();
+ PsiClass psiClass = classResolveResult.getElement();
+ if (psiClass == null) {
+ return false; // can't resolve class -> not a SAM interface
+ }
+ if (CommonClassNames.JAVA_LANG_OBJECT.equals(psiClass.getQualifiedName())) {
+ return true;
+ }
+ for (PsiMethod method : psiClass.getMethods()) {
+ if (isObjectMethod(method)) { // e.g., ignore toString() declared in interface
+ continue;
+ }
+ if (method.hasTypeParameters()) {
+ return false; // if interface has generic methods, it is not a SAM interface
+ }
+
+ if (found == null) {
+ found = (MethodSignatureBackedByPsiMethod) method.getSignature(classSubstitutor);
+ continue;
+ }
+ if (!found.getName().equals(method.getName())) {
+ return false; // optimizing heuristic
+ }
+ MethodSignatureBackedByPsiMethod current = (MethodSignatureBackedByPsiMethod) method.getSignature(classSubstitutor);
+ if (!areSignaturesErasureEqual(current, found) || isVarargMethod(method) != isVarargMethod(found.getMethod())) {
+ return false; // different signatures
+ }
+ }
+
+ for (PsiType t : classType.getSuperTypes()) {
+ if (!find((PsiClassType) t)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ @Nullable
+ PsiMethod getFoundMethod() {
+ return found == null ? null : found.getMethod();
+ }
+ }
}
diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaClassObjectResolver.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaClassObjectResolver.java
index 8bf16a28584..5f59d056aee 100644
--- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaClassObjectResolver.java
+++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaClassObjectResolver.java
@@ -149,7 +149,7 @@ public final class JavaClassObjectResolver {
classObjectDescriptor.createTypeConstructor();
JavaClassNonStaticMembersScope classMembersScope = new JavaClassNonStaticMembersScope(classObjectDescriptor, data, semanticServices);
WritableScopeImpl writableScope =
- new WritableScopeImpl(classMembersScope, classObjectDescriptor, RedeclarationHandler.THROW_EXCEPTION, fqName.toString());
+ new WritableScopeImpl(classMembersScope, classObjectDescriptor, RedeclarationHandler.THROW_EXCEPTION, "Member lookup scope");
writableScope.changeLockLevel(WritableScope.LockLevel.BOTH);
classObjectDescriptor.setScopeForMemberLookup(writableScope);
classObjectDescriptor.setScopeForConstructorResolve(classMembersScope);
diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaClassResolver.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaClassResolver.java
index f280910e44e..eeeab66ec1c 100644
--- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaClassResolver.java
+++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaClassResolver.java
@@ -45,6 +45,7 @@ import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeUtils;
+import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
import javax.inject.Inject;
import java.util.ArrayList;
@@ -276,7 +277,7 @@ public final class JavaClassResolver {
PsiMethod samInterfaceMethod = MembersCache.getSamInterfaceMethod(psiClass);
if (samInterfaceMethod != null) {
- SimpleFunctionDescriptor abstractMethod = resolveFunctionOfSamInterface(psiClass, samInterfaceMethod, classDescriptor);
+ SimpleFunctionDescriptor abstractMethod = resolveFunctionOfSamInterface(samInterfaceMethod, classDescriptor);
classDescriptor.setFunctionTypeForSamInterface(SingleAbstractMethodUtils.getFunctionTypeForAbstractMethod(abstractMethod));
}
@@ -285,14 +286,13 @@ public final class JavaClassResolver {
@NotNull
private SimpleFunctionDescriptor resolveFunctionOfSamInterface(
- @NotNull PsiClass psiClass,
@NotNull PsiMethod samInterfaceMethod,
@NotNull ClassDescriptorFromJvmBytecode samInterface
) {
PsiClass methodContainer = samInterfaceMethod.getContainingClass();
- assert methodContainer != null : "method container is null for " + methodContainer;
+ assert methodContainer != null : "method container is null for " + samInterfaceMethod;
String containerQualifiedName = methodContainer.getQualifiedName();
- assert containerQualifiedName != null : "qualified name is null for " + psiClass;
+ assert containerQualifiedName != null : "qualified name is null for " + methodContainer;
if (DescriptorUtils.getFQName(samInterface).asString().equals(containerQualifiedName)) {
SimpleFunctionDescriptor abstractMethod =
@@ -301,15 +301,28 @@ public final class JavaClassResolver {
return abstractMethod;
}
else {
- Set supertypes = TypeUtils.getAllSupertypes(samInterface.getDefaultType());
- for (JetType supertype : supertypes) {
- List abstractMembers = SingleAbstractMethodUtils.getAbstractMembers(supertype);
- if (!abstractMembers.isEmpty()) {
- return (SimpleFunctionDescriptor) abstractMembers.get(0);
- }
+ return findFunctionWithMostSpecificReturnType(TypeUtils.getAllSupertypes(samInterface.getDefaultType()));
+ }
+ }
+
+ private static SimpleFunctionDescriptor findFunctionWithMostSpecificReturnType(@NotNull Set supertypes) {
+ List candidates = Lists.newArrayList();
+ for (JetType supertype : supertypes) {
+ List abstractMembers = SingleAbstractMethodUtils.getAbstractMembers(supertype);
+ if (!abstractMembers.isEmpty()) {
+ candidates.add((SimpleFunctionDescriptor) abstractMembers.get(0));
}
+ }
+ if (candidates.isEmpty()) {
throw new IllegalStateException("Couldn't find abstract method in supertypes " + supertypes);
}
+ SimpleFunctionDescriptor currentMostSpecificType = candidates.get(0);
+ for (SimpleFunctionDescriptor candidate : candidates) {
+ if (JetTypeChecker.INSTANCE.isSubtypeOf(candidate.getReturnType(), currentMostSpecificType.getReturnType())) {
+ currentMostSpecificType = candidate;
+ }
+ }
+ return currentMostSpecificType;
}
private void cache(@NotNull FqNameBase fqName, @Nullable ClassDescriptor classDescriptor) {
diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaConstructorResolver.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaConstructorResolver.java
index 812e92143cd..00e6f40e468 100644
--- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaConstructorResolver.java
+++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaConstructorResolver.java
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.resolve.java.resolver;
import com.google.common.collect.Lists;
import com.intellij.psi.*;
+import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
@@ -40,6 +41,10 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import static org.jetbrains.jet.lang.resolve.java.resolver.JavaFunctionResolver.recordSamAdapter;
+import static org.jetbrains.jet.lang.resolve.java.sam.SingleAbstractMethodUtils.createSamAdapterConstructor;
+import static org.jetbrains.jet.lang.resolve.java.sam.SingleAbstractMethodUtils.isSamAdapterNecessary;
+
public final class JavaConstructorResolver {
private BindingTrace trace;
private JavaTypeTransformer typeTransformer;
@@ -149,6 +154,7 @@ public final class JavaConstructorResolver {
ConstructorDescriptor constructor = resolveConstructor(psiClass, isStatic, psiConstructor, containingClass);
if (constructor != null) {
constructors.add(constructor);
+ ContainerUtil.addIfNotNull(constructors, resolveSamAdapter(constructor));
}
}
}
@@ -207,7 +213,7 @@ public final class JavaConstructorResolver {
valueParameterDescriptors = alternativeMethodSignatureData.getValueParameters();
}
else if (alternativeMethodSignatureData.hasErrors()) {
- trace.record(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, constructorDescriptor,
+ trace.record(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, constructorDescriptor,
Collections.singletonList(alternativeMethodSignatureData.getError()));
}
@@ -218,4 +224,11 @@ public final class JavaConstructorResolver {
trace.record(BindingContext.CONSTRUCTOR, psiConstructor, constructorDescriptor);
return constructorDescriptor;
}
+
+ @Nullable
+ private ConstructorDescriptor resolveSamAdapter(@NotNull ConstructorDescriptor original) {
+ return isSamAdapterNecessary(original)
+ ? recordSamAdapter(original, createSamAdapterConstructor(original), trace)
+ : null;
+ }
}
\ No newline at end of file
diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaFunctionResolver.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaFunctionResolver.java
index 8372ed45dc2..71cf1a6972d 100644
--- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaFunctionResolver.java
+++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaFunctionResolver.java
@@ -31,11 +31,11 @@ import org.jetbrains.jet.lang.descriptors.impl.NamespaceDescriptorParent;
import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
import org.jetbrains.jet.lang.resolve.*;
import org.jetbrains.jet.lang.resolve.java.*;
+import org.jetbrains.jet.lang.resolve.java.descriptor.ClassDescriptorFromJvmBytecode;
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.AlternativeMethodSignatureData;
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.SignaturesPropagationData;
import org.jetbrains.jet.lang.resolve.java.kt.DescriptorKindUtils;
import org.jetbrains.jet.lang.resolve.java.provider.*;
-import org.jetbrains.jet.lang.resolve.java.sam.SingleAbstractMethodUtils;
import org.jetbrains.jet.lang.resolve.java.wrapper.PsiMethodWrapper;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
@@ -52,6 +52,7 @@ import static org.jetbrains.jet.lang.resolve.DescriptorUtils.*;
import static org.jetbrains.jet.lang.resolve.OverridingUtil.*;
import static org.jetbrains.jet.lang.resolve.java.provider.DeclarationOrigin.JAVA;
import static org.jetbrains.jet.lang.resolve.java.provider.DeclarationOrigin.KOTLIN;
+import static org.jetbrains.jet.lang.resolve.java.sam.SingleAbstractMethodUtils.*;
public final class JavaFunctionResolver {
private static final Logger LOG = Logger.getInstance(JavaFunctionResolver.class);
@@ -201,7 +202,7 @@ public final class JavaFunctionResolver {
}
if (declarationOrigin == JAVA && record) {
- trace.record(BindingContext.IS_DECLARED_IN_JAVA, functionDescriptorImpl);
+ trace.record(JavaBindingContext.IS_DECLARED_IN_JAVA, functionDescriptorImpl);
}
if (containingClass != psiClass && !method.isStatic()) {
@@ -216,7 +217,7 @@ public final class JavaFunctionResolver {
}
else {
if (record) {
- trace.record(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, functionDescriptorImpl, signatureErrors);
+ trace.record(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, functionDescriptorImpl, signatureErrors);
}
}
}
@@ -267,7 +268,6 @@ public final class JavaFunctionResolver {
@NotNull ClassOrNamespaceDescriptor owner, @NotNull PsiClass psiClass,
NamedMembers namedMembers, Name methodName, PsiDeclarationProvider scopeData
) {
- final Set functions = new HashSet();
Set functionsFromSupertypes = null;
if (owner instanceof ClassDescriptor) {
@@ -290,6 +290,8 @@ public final class JavaFunctionResolver {
ContainerUtil.addIfNotNull(functionsFromCurrent, resolveSamConstructor((NamespaceDescriptor) owner, namedMembers));
}
+
+ final Set fakeOverrides = new HashSet();
if (owner instanceof ClassDescriptor) {
ClassDescriptor classDescriptor = (ClassDescriptor) owner;
@@ -297,7 +299,7 @@ public final class JavaFunctionResolver {
new OverrideResolver.DescriptorSink() {
@Override
public void addToScope(@NotNull CallableMemberDescriptor fakeOverride) {
- functions.add((FunctionDescriptor) fakeOverride);
+ fakeOverrides.add((FunctionDescriptor) fakeOverride);
}
@Override
@@ -310,25 +312,28 @@ public final class JavaFunctionResolver {
});
}
- OverrideResolver.resolveUnknownVisibilities(functions, trace);
- functions.addAll(functionsFromCurrent);
+ OverrideResolver.resolveUnknownVisibilities(fakeOverrides, trace);
+ Set functions = Sets.newHashSet(fakeOverrides);
if (isEnumClassObject(owner)) {
- for (FunctionDescriptor functionDescriptor : Lists.newArrayList(functions)) {
- if (isEnumValueOfMethod(functionDescriptor) || isEnumValuesMethod(functionDescriptor)) {
- functions.remove(functionDescriptor);
+ for (FunctionDescriptor functionDescriptor : functionsFromCurrent) {
+ if (!(isEnumValueOfMethod(functionDescriptor) || isEnumValuesMethod(functionDescriptor))) {
+ functions.add(functionDescriptor);
}
}
}
+ else {
+ functions.addAll(functionsFromCurrent);
+ }
return functions;
}
@Nullable
- private static ClassDescriptor findClassInScope(@NotNull JetScope memberScope, @NotNull Name name) {
+ private static ClassDescriptorFromJvmBytecode findClassInScope(@NotNull JetScope memberScope, @NotNull Name name) {
ClassifierDescriptor classifier = memberScope.getClassifier(name);
- if (classifier instanceof ClassDescriptor) {
- return (ClassDescriptor) classifier;
+ if (classifier instanceof ClassDescriptorFromJvmBytecode) {
+ return (ClassDescriptorFromJvmBytecode) classifier;
}
return null;
}
@@ -340,9 +345,9 @@ public final class JavaFunctionResolver {
// +-- namespace Bar
// We need to find class 'Baz' in namespace 'foo.Bar'.
@Nullable
- private static ClassDescriptor findClassInNamespace(@NotNull NamespaceDescriptor namespace, @NotNull Name name) {
+ private static ClassDescriptorFromJvmBytecode findClassInNamespace(@NotNull NamespaceDescriptor namespace, @NotNull Name name) {
// First, try to find in namespace directly
- ClassDescriptor found = findClassInScope(namespace.getMemberScope(), name);
+ ClassDescriptorFromJvmBytecode found = findClassInScope(namespace.getMemberScope(), name);
if (found != null) {
return found;
}
@@ -369,13 +374,9 @@ public final class JavaFunctionResolver {
) {
PsiClass samInterface = namedMembers.getSamInterface();
if (samInterface != null) {
- ClassDescriptor klass = findClassInNamespace(ownerDescriptor, namedMembers.getName());
+ ClassDescriptorFromJvmBytecode klass = findClassInNamespace(ownerDescriptor, namedMembers.getName());
if (klass != null) {
- SimpleFunctionDescriptor constructorFunction = SingleAbstractMethodUtils.createSamConstructorFunction(ownerDescriptor,
- klass);
- trace.record(BindingContext.SAM_CONSTRUCTOR_TO_INTERFACE, constructorFunction, klass);
- trace.record(BindingContext.SOURCE_DESCRIPTOR_FOR_SYNTHESIZED, constructorFunction, klass);
- return constructorFunction;
+ return recordSamConstructor(klass, createSamConstructorFunction(ownerDescriptor, klass), trace);
}
}
return null;
@@ -383,14 +384,9 @@ public final class JavaFunctionResolver {
@Nullable
private SimpleFunctionDescriptor resolveSamAdapter(@NotNull SimpleFunctionDescriptor original) {
- if (SingleAbstractMethodUtils.isSamAdapterNecessary(original)) {
- SimpleFunctionDescriptor adapterFunction = SingleAbstractMethodUtils.createSamAdapterFunction(original);
-
- trace.record(BindingContext.SAM_ADAPTER_FUNCTION_TO_ORIGINAL, adapterFunction, original);
- trace.record(BindingContext.SOURCE_DESCRIPTOR_FOR_SYNTHESIZED, adapterFunction, original);
- return adapterFunction;
- }
- return null;
+ return isSamAdapterNecessary(original)
+ ? recordSamAdapter(original, createSamAdapterFunction(original), trace)
+ : null;
}
@NotNull
@@ -496,4 +492,16 @@ public final class JavaFunctionResolver {
return false;
}
+
+ private static SimpleFunctionDescriptor recordSamConstructor(ClassDescriptorFromJvmBytecode klass, SimpleFunctionDescriptor constructorFunction, BindingTrace trace) {
+ trace.record(JavaBindingContext.SAM_CONSTRUCTOR_TO_INTERFACE, constructorFunction, klass);
+ trace.record(BindingContext.SOURCE_DESCRIPTOR_FOR_SYNTHESIZED, constructorFunction, klass);
+ return constructorFunction;
+ }
+
+ static F recordSamAdapter(F original, F adapterFunction, BindingTrace trace) {
+ trace.record(JavaBindingContext.SAM_ADAPTER_FUNCTION_TO_ORIGINAL, adapterFunction, original);
+ trace.record(BindingContext.SOURCE_DESCRIPTOR_FOR_SYNTHESIZED, adapterFunction, original);
+ return adapterFunction;
+ }
}
\ No newline at end of file
diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaPropertyResolver.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaPropertyResolver.java
index 43bdd800784..9c9cf23d4bb 100644
--- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaPropertyResolver.java
+++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaPropertyResolver.java
@@ -241,7 +241,7 @@ public final class JavaPropertyResolver {
recordObjectDeclarationClassIfNeeded(psiData, owner, propertyDescriptor, propertyType);
if (scopeData.getDeclarationOrigin() == JAVA) {
- trace.record(BindingContext.IS_DECLARED_IN_JAVA, propertyDescriptor);
+ trace.record(JavaBindingContext.IS_DECLARED_IN_JAVA, propertyDescriptor);
}
return propertyDescriptor;
}
@@ -264,7 +264,7 @@ public final class JavaPropertyResolver {
}
}
else {
- trace.record(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, propertyDescriptor,
+ trace.record(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, propertyDescriptor,
Collections.singletonList(signatureData.getError()));
}
return propertyType;
diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/sam/SingleAbstractMethodUtils.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/sam/SingleAbstractMethodUtils.java
index 791161d5abc..ed9122d5327 100644
--- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/sam/SingleAbstractMethodUtils.java
+++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/sam/SingleAbstractMethodUtils.java
@@ -21,9 +21,11 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
+import org.jetbrains.jet.lang.descriptors.impl.ConstructorDescriptorImpl;
import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl;
import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl;
+import org.jetbrains.jet.lang.resolve.calls.CallResolverUtil;
import org.jetbrains.jet.lang.resolve.java.descriptor.ClassDescriptorFromJvmBytecode;
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.SignaturesUtil;
import org.jetbrains.jet.lang.resolve.name.Name;
@@ -44,15 +46,14 @@ public class SingleAbstractMethodUtils {
List abstractMembers = Lists.newArrayList();
for (DeclarationDescriptor member : type.getMemberScope().getAllDescriptors()) {
if (member instanceof CallableMemberDescriptor &&
- ((CallableMemberDescriptor) member).getModality() == Modality.ABSTRACT &&
- ((CallableMemberDescriptor) member).getKind() != CallableMemberDescriptor.Kind.SYNTHESIZED) {
+ ((CallableMemberDescriptor) member).getModality() == Modality.ABSTRACT &&
+ !CallResolverUtil.isOrOverridesSynthesized((CallableMemberDescriptor) member)) {
abstractMembers.add((CallableMemberDescriptor) member);
}
}
return abstractMembers;
}
- // TODO maybe do this in substitutor?
private static JetType fixProjections(@NotNull JetType functionType) {
//removes redundant projection kinds and detects conflicts
@@ -174,7 +175,7 @@ public class SingleAbstractMethodUtils {
return getFunctionTypeForSamType(type) != null;
}
- public static boolean isSamAdapterNecessary(@NotNull SimpleFunctionDescriptor fun) {
+ public static boolean isSamAdapterNecessary(@NotNull FunctionDescriptor fun) {
for (ValueParameterDescriptor param : fun.getValueParameters()) {
if (isSamType(param.getType())) {
return true;
@@ -184,20 +185,77 @@ public class SingleAbstractMethodUtils {
}
@NotNull
- public static SimpleFunctionDescriptor createSamAdapterFunction(@NotNull SimpleFunctionDescriptor original) {
- SimpleFunctionDescriptorImpl result = new SimpleFunctionDescriptorImpl(
+ public static SimpleFunctionDescriptor createSamAdapterFunction(@NotNull final SimpleFunctionDescriptor original) {
+ final SimpleFunctionDescriptorImpl result = new SimpleFunctionDescriptorImpl(
original.getContainingDeclaration(),
original.getAnnotations(),
original.getName(),
CallableMemberDescriptor.Kind.SYNTHESIZED
);
+ FunctionInitializer initializer = new FunctionInitializer() {
+ @Override
+ public void initialize(
+ @NotNull List typeParameters,
+ @NotNull List valueParameters,
+ @Nullable JetType returnType
+ ) {
+ result.initialize(
+ null,
+ original.getExpectedThisObject(),
+ typeParameters,
+ valueParameters,
+ returnType,
+ original.getModality(),
+ original.getVisibility(),
+ false
+ );
+ }
+ };
+ return initSamAdapter(original, result, initializer);
+ }
- TypeParameters typeParameters = recreateAndInitializeTypeParameters(original.getTypeParameters(), result);
+ @NotNull
+ public static ConstructorDescriptor createSamAdapterConstructor(@NotNull final ConstructorDescriptor original) {
+ final ConstructorDescriptorImpl result = new ConstructorDescriptorImpl(
+ original.getContainingDeclaration(),
+ original.getAnnotations(),
+ original.isPrimary(),
+ CallableMemberDescriptor.Kind.SYNTHESIZED
+ );
+ FunctionInitializer initializer = new FunctionInitializer() {
+ @Override
+ public void initialize(
+ @NotNull List typeParameters,
+ @NotNull List valueParameters,
+ @Nullable JetType returnType
+ ) {
+ result.initialize(
+ typeParameters,
+ valueParameters,
+ original.getVisibility(),
+ original.getExpectedThisObject() == ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER
+ );
+ }
+ };
+ return initSamAdapter(original, result, initializer);
+ }
+
+ private static F initSamAdapter(
+ @NotNull F original,
+ @NotNull F adapter,
+ @NotNull FunctionInitializer initializer
+ ) {
+ TypeParameters typeParameters = recreateAndInitializeTypeParameters(original.getTypeParameters(), adapter);
JetType returnTypeUnsubstituted = original.getReturnType();
- assert returnTypeUnsubstituted != null : original;
- JetType returnType = typeParameters.substitutor.substitute(returnTypeUnsubstituted, Variance.OUT_VARIANCE);
- assert returnType != null : "couldn't substitute type: " + returnType + ", substitutor = " + typeParameters.substitutor;
+ JetType returnType;
+ if (returnTypeUnsubstituted == null) { // return type may be null for not yet initialized constructors
+ returnType = null;
+ }
+ else {
+ returnType = typeParameters.substitutor.substitute(returnTypeUnsubstituted, Variance.OUT_VARIANCE);
+ assert returnType != null : "couldn't substitute type: " + returnType + ", substitutor = " + typeParameters.substitutor;
+ }
List valueParameters = Lists.newArrayList();
for (ValueParameterDescriptor originalParam : original.getValueParameters()) {
@@ -208,22 +266,12 @@ public class SingleAbstractMethodUtils {
assert newType != null : "couldn't substitute type: " + newTypeUnsubstituted + ", substitutor = " + typeParameters.substitutor;
ValueParameterDescriptor newParam = new ValueParameterDescriptorImpl(
- result, originalParam.getIndex(), originalParam.getAnnotations(), originalParam.getName(), newType, false, null);
+ adapter, originalParam.getIndex(), originalParam.getAnnotations(), originalParam.getName(), newType, false, null);
valueParameters.add(newParam);
}
- result.initialize(
- null,
- original.getExpectedThisObject(),
- typeParameters.descriptors,
- valueParameters,
- returnType,
- original.getModality(),
- original.getVisibility(),
- false
- );
-
- return result;
+ initializer.initialize(typeParameters.descriptors, valueParameters, returnType);
+ return adapter;
}
@NotNull
@@ -273,4 +321,12 @@ public class SingleAbstractMethodUtils {
this.substitutor = substitutor;
}
}
+
+ private static abstract class FunctionInitializer {
+ public abstract void initialize(
+ @NotNull List typeParameters,
+ @NotNull List valueParameters,
+ @Nullable JetType returnType
+ );
+ }
}
diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/scope/JavaBaseScope.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/scope/JavaBaseScope.java
index 74628e966a8..6f1edf2f678 100644
--- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/scope/JavaBaseScope.java
+++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/scope/JavaBaseScope.java
@@ -20,7 +20,9 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.intellij.openapi.progress.ProgressIndicatorProvider;
+import com.intellij.openapi.util.Condition;
import com.intellij.psi.PsiElement;
+import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
@@ -33,10 +35,7 @@ import org.jetbrains.jet.lang.resolve.java.provider.PsiDeclarationProvider;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.JetScopeImpl;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
public abstract class JavaBaseScope extends JetScopeImpl {
@@ -50,6 +49,8 @@ public abstract class JavaBaseScope extends JetScopeImpl {
private final Map> propertyDescriptors = Maps.newHashMap();
@Nullable
private Collection allDescriptors = null;
+ @Nullable
+ private Set objectDescriptors = null;
@NotNull
protected final ClassOrNamespaceDescriptor descriptor;
@@ -130,10 +131,19 @@ public abstract class JavaBaseScope extends JetScopeImpl {
protected Collection computeAllDescriptors() {
Collection result = Sets.newHashSet();
result.addAll(computeFieldAndFunctionDescriptors());
- result.addAll(getInnerClasses());
+ result.addAll(filterObjects(getInnerClasses(), false));
return result;
}
+ @NotNull
+ @Override
+ public Set getObjectDescriptors() {
+ if (objectDescriptors == null) {
+ objectDescriptors = new HashSet(filterObjects(getInnerClasses(), true));
+ }
+ return objectDescriptors;
+ }
+
@NotNull
protected abstract Collection computeInnerClasses();
@@ -174,4 +184,13 @@ public abstract class JavaBaseScope extends JetScopeImpl {
}
return innerClasses;
}
+
+ private static Collection filterObjects(Collection classes, final boolean objects) {
+ return ContainerUtil.filter(classes, new Condition() {
+ @Override
+ public boolean value(T classDescriptor) {
+ return classDescriptor.getKind().isObject() == objects;
+ }
+ });
+ }
}
diff --git a/compiler/frontend/src/org/jetbrains/jet/di/InjectorForBodyResolve.java b/compiler/frontend/src/org/jetbrains/jet/di/InjectorForBodyResolve.java
index 2e403ff5caa..ac6bb8a5ad6 100644
--- a/compiler/frontend/src/org/jetbrains/jet/di/InjectorForBodyResolve.java
+++ b/compiler/frontend/src/org/jetbrains/jet/di/InjectorForBodyResolve.java
@@ -17,17 +17,18 @@
package org.jetbrains.jet.di;
import org.jetbrains.jet.lang.resolve.BodyResolver;
+import org.jetbrains.jet.lang.resolve.calls.NeedSyntheticCallResolverExtension;
import com.intellij.openapi.project.Project;
import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters;
import org.jetbrains.jet.lang.resolve.BindingTrace;
import org.jetbrains.jet.lang.resolve.BodiesResolveContext;
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
+import org.jetbrains.jet.lang.resolve.AnnotationResolver;
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
import org.jetbrains.jet.lang.resolve.calls.ArgumentTypeResolver;
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices;
import org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver;
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
-import org.jetbrains.jet.lang.resolve.AnnotationResolver;
import org.jetbrains.jet.lang.resolve.TypeResolver;
import org.jetbrains.jet.lang.resolve.QualifiedExpressionResolver;
import org.jetbrains.jet.lang.resolve.calls.CandidateResolver;
@@ -42,17 +43,18 @@ import javax.annotation.PreDestroy;
public class InjectorForBodyResolve {
private BodyResolver bodyResolver;
+ private NeedSyntheticCallResolverExtension needSyntheticCallResolverExtension;
private final Project project;
private final TopDownAnalysisParameters topDownAnalysisParameters;
private final BindingTrace bindingTrace;
private final BodiesResolveContext bodiesResolveContext;
private final ModuleDescriptor moduleDescriptor;
+ private AnnotationResolver annotationResolver;
private CallResolver callResolver;
private ArgumentTypeResolver argumentTypeResolver;
private ExpressionTypingServices expressionTypingServices;
private CallExpressionResolver callExpressionResolver;
private DescriptorResolver descriptorResolver;
- private AnnotationResolver annotationResolver;
private TypeResolver typeResolver;
private QualifiedExpressionResolver qualifiedExpressionResolver;
private CandidateResolver candidateResolver;
@@ -69,17 +71,18 @@ public class InjectorForBodyResolve {
@NotNull ModuleDescriptor moduleDescriptor
) {
this.bodyResolver = new BodyResolver();
+ this.needSyntheticCallResolverExtension = new NeedSyntheticCallResolverExtension();
this.project = project;
this.topDownAnalysisParameters = topDownAnalysisParameters;
this.bindingTrace = bindingTrace;
this.bodiesResolveContext = bodiesResolveContext;
this.moduleDescriptor = moduleDescriptor;
+ this.annotationResolver = new AnnotationResolver();
this.callResolver = new CallResolver();
this.argumentTypeResolver = new ArgumentTypeResolver();
this.expressionTypingServices = new ExpressionTypingServices();
this.callExpressionResolver = new CallExpressionResolver();
this.descriptorResolver = new DescriptorResolver();
- this.annotationResolver = new AnnotationResolver();
this.typeResolver = new TypeResolver();
this.qualifiedExpressionResolver = new QualifiedExpressionResolver();
this.candidateResolver = new CandidateResolver();
@@ -88,6 +91,7 @@ public class InjectorForBodyResolve {
this.scriptBodyResolver = new ScriptBodyResolver();
this.topDownAnalysisContext = new TopDownAnalysisContext();
+ this.bodyResolver.setAnnotationResolver(annotationResolver);
this.bodyResolver.setCallResolver(callResolver);
this.bodyResolver.setContext(bodiesResolveContext);
this.bodyResolver.setControlFlowAnalyzer(controlFlowAnalyzer);
@@ -98,9 +102,13 @@ public class InjectorForBodyResolve {
this.bodyResolver.setTopDownAnalysisParameters(topDownAnalysisParameters);
this.bodyResolver.setTrace(bindingTrace);
+ annotationResolver.setCallResolver(callResolver);
+ annotationResolver.setExpressionTypingServices(expressionTypingServices);
+
callResolver.setArgumentTypeResolver(argumentTypeResolver);
callResolver.setCandidateResolver(candidateResolver);
callResolver.setExpressionTypingServices(expressionTypingServices);
+ callResolver.setExtension(needSyntheticCallResolverExtension);
callResolver.setTypeResolver(typeResolver);
argumentTypeResolver.setExpressionTypingServices(expressionTypingServices);
@@ -118,9 +126,6 @@ public class InjectorForBodyResolve {
descriptorResolver.setExpressionTypingServices(expressionTypingServices);
descriptorResolver.setTypeResolver(typeResolver);
- annotationResolver.setCallResolver(callResolver);
- annotationResolver.setExpressionTypingServices(expressionTypingServices);
-
typeResolver.setAnnotationResolver(annotationResolver);
typeResolver.setDescriptorResolver(descriptorResolver);
typeResolver.setModuleDescriptor(moduleDescriptor);
diff --git a/compiler/frontend/src/org/jetbrains/jet/di/InjectorForLazyResolve.java b/compiler/frontend/src/org/jetbrains/jet/di/InjectorForLazyResolve.java
index 75abc36457b..845263ea0ca 100644
--- a/compiler/frontend/src/org/jetbrains/jet/di/InjectorForLazyResolve.java
+++ b/compiler/frontend/src/org/jetbrains/jet/di/InjectorForLazyResolve.java
@@ -26,6 +26,7 @@ import org.jetbrains.jet.lang.resolve.lazy.ScopeProvider;
import org.jetbrains.jet.lang.resolve.AnnotationResolver;
import org.jetbrains.jet.lang.resolve.QualifiedExpressionResolver;
import org.jetbrains.jet.lang.psi.JetImportsFactory;
+import org.jetbrains.jet.lang.resolve.calls.NeedSyntheticCallResolverExtension;
import org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver;
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
import org.jetbrains.jet.lang.resolve.calls.ArgumentTypeResolver;
@@ -46,6 +47,7 @@ public class InjectorForLazyResolve {
private AnnotationResolver annotationResolver;
private QualifiedExpressionResolver qualifiedExpressionResolver;
private JetImportsFactory jetImportsFactory;
+ private NeedSyntheticCallResolverExtension needSyntheticCallResolverExtension;
private CallExpressionResolver callExpressionResolver;
private CallResolver callResolver;
private ArgumentTypeResolver argumentTypeResolver;
@@ -66,6 +68,7 @@ public class InjectorForLazyResolve {
this.annotationResolver = new AnnotationResolver();
this.qualifiedExpressionResolver = new QualifiedExpressionResolver();
this.jetImportsFactory = new JetImportsFactory();
+ this.needSyntheticCallResolverExtension = new NeedSyntheticCallResolverExtension();
this.callExpressionResolver = new CallExpressionResolver();
this.callResolver = new CallResolver();
this.argumentTypeResolver = new ArgumentTypeResolver();
@@ -96,6 +99,7 @@ public class InjectorForLazyResolve {
callResolver.setArgumentTypeResolver(argumentTypeResolver);
callResolver.setCandidateResolver(candidateResolver);
callResolver.setExpressionTypingServices(expressionTypingServices);
+ callResolver.setExtension(needSyntheticCallResolverExtension);
callResolver.setTypeResolver(typeResolver);
argumentTypeResolver.setExpressionTypingServices(expressionTypingServices);
diff --git a/compiler/frontend/src/org/jetbrains/jet/di/InjectorForMacros.java b/compiler/frontend/src/org/jetbrains/jet/di/InjectorForMacros.java
index 72b331eb103..b4625f5ba1f 100644
--- a/compiler/frontend/src/org/jetbrains/jet/di/InjectorForMacros.java
+++ b/compiler/frontend/src/org/jetbrains/jet/di/InjectorForMacros.java
@@ -17,6 +17,7 @@
package org.jetbrains.jet.di;
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices;
+import org.jetbrains.jet.lang.resolve.calls.NeedSyntheticCallResolverExtension;
import com.intellij.openapi.project.Project;
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor;
import org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver;
@@ -34,6 +35,7 @@ import javax.annotation.PreDestroy;
public class InjectorForMacros {
private ExpressionTypingServices expressionTypingServices;
+ private NeedSyntheticCallResolverExtension needSyntheticCallResolverExtension;
private final Project project;
private final ModuleDescriptor moduleDescriptor;
private CallExpressionResolver callExpressionResolver;
@@ -50,6 +52,7 @@ public class InjectorForMacros {
@NotNull ModuleDescriptor moduleDescriptor
) {
this.expressionTypingServices = new ExpressionTypingServices();
+ this.needSyntheticCallResolverExtension = new NeedSyntheticCallResolverExtension();
this.project = project;
this.moduleDescriptor = moduleDescriptor;
this.callExpressionResolver = new CallExpressionResolver();
@@ -72,6 +75,7 @@ public class InjectorForMacros {
callResolver.setArgumentTypeResolver(argumentTypeResolver);
callResolver.setCandidateResolver(candidateResolver);
callResolver.setExpressionTypingServices(expressionTypingServices);
+ callResolver.setExtension(needSyntheticCallResolverExtension);
callResolver.setTypeResolver(typeResolver);
argumentTypeResolver.setExpressionTypingServices(expressionTypingServices);
diff --git a/compiler/frontend/src/org/jetbrains/jet/di/InjectorForTopDownAnalyzerBasic.java b/compiler/frontend/src/org/jetbrains/jet/di/InjectorForTopDownAnalyzerBasic.java
index c79fe48893c..5e1e7e47cd7 100644
--- a/compiler/frontend/src/org/jetbrains/jet/di/InjectorForTopDownAnalyzerBasic.java
+++ b/compiler/frontend/src/org/jetbrains/jet/di/InjectorForTopDownAnalyzerBasic.java
@@ -22,6 +22,7 @@ import org.jetbrains.jet.lang.resolve.BodyResolver;
import org.jetbrains.jet.lang.resolve.ControlFlowAnalyzer;
import org.jetbrains.jet.lang.resolve.DeclarationsChecker;
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
+import org.jetbrains.jet.lang.resolve.calls.NeedSyntheticCallResolverExtension;
import com.intellij.openapi.project.Project;
import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters;
import org.jetbrains.jet.lang.resolve.BindingTrace;
@@ -56,6 +57,7 @@ public class InjectorForTopDownAnalyzerBasic {
private ControlFlowAnalyzer controlFlowAnalyzer;
private DeclarationsChecker declarationsChecker;
private DescriptorResolver descriptorResolver;
+ private NeedSyntheticCallResolverExtension needSyntheticCallResolverExtension;
private final Project project;
private final TopDownAnalysisParameters topDownAnalysisParameters;
private final BindingTrace bindingTrace;
@@ -91,6 +93,7 @@ public class InjectorForTopDownAnalyzerBasic {
this.controlFlowAnalyzer = new ControlFlowAnalyzer();
this.declarationsChecker = new DeclarationsChecker();
this.descriptorResolver = new DescriptorResolver();
+ this.needSyntheticCallResolverExtension = new NeedSyntheticCallResolverExtension();
this.project = project;
this.topDownAnalysisParameters = topDownAnalysisParameters;
this.bindingTrace = bindingTrace;
@@ -127,6 +130,7 @@ public class InjectorForTopDownAnalyzerBasic {
this.topDownAnalysisContext.setTopDownAnalysisParameters(topDownAnalysisParameters);
+ this.bodyResolver.setAnnotationResolver(annotationResolver);
this.bodyResolver.setCallResolver(callResolver);
this.bodyResolver.setContext(topDownAnalysisContext);
this.bodyResolver.setControlFlowAnalyzer(controlFlowAnalyzer);
@@ -162,6 +166,7 @@ public class InjectorForTopDownAnalyzerBasic {
callResolver.setArgumentTypeResolver(argumentTypeResolver);
callResolver.setCandidateResolver(candidateResolver);
callResolver.setExpressionTypingServices(expressionTypingServices);
+ callResolver.setExtension(needSyntheticCallResolverExtension);
callResolver.setTypeResolver(typeResolver);
argumentTypeResolver.setExpressionTypingServices(expressionTypingServices);
diff --git a/compiler/frontend/src/org/jetbrains/jet/kdoc/lexer/KDocTokens.java b/compiler/frontend/src/org/jetbrains/jet/kdoc/lexer/KDocTokens.java
index da637335958..fbcf0102867 100644
--- a/compiler/frontend/src/org/jetbrains/jet/kdoc/lexer/KDocTokens.java
+++ b/compiler/frontend/src/org/jetbrains/jet/kdoc/lexer/KDocTokens.java
@@ -60,5 +60,6 @@ public interface KDocTokens {
KDocToken MARKDOWN_ESCAPED_CHAR = new KDocToken("KDOC_MARKDOWN_ESCAPED_CHAR");
- TokenSet CONTENT_TOKENS = TokenSet.create(START, END, LEADING_ASTERISK, TEXT, WIKI_LINK_OPEN, WIKI_LINK_CLOSE, MARKDOWN_ESCAPED_CHAR);
+ TokenSet KDOC_HIGHLIGHT_TOKENS = TokenSet.create(START, END, LEADING_ASTERISK, TEXT, WIKI_LINK_OPEN, WIKI_LINK_CLOSE, MARKDOWN_ESCAPED_CHAR);
+ TokenSet CONTENT_TOKENS = TokenSet.create(TEXT, TAG_NAME, WIKI_LINK_OPEN, WIKI_LINK_CLOSE, MARKDOWN_ESCAPED_CHAR);
}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassifierDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassifierDescriptor.java
index 7ddd70998ad..e17dd7a8514 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassifierDescriptor.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/ClassifierDescriptor.java
@@ -30,6 +30,4 @@ public interface ClassifierDescriptor extends DeclarationDescriptorNonRoot {
@Nullable
JetType getClassObjectType();
-
- boolean isClassObjectAValue();
}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/VariableDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/VariableDescriptor.java
index ef8783889f3..b9d164f1dfd 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/VariableDescriptor.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/VariableDescriptor.java
@@ -25,7 +25,6 @@ public interface VariableDescriptor extends CallableDescriptor {
JetType getType();
@Override
- @SuppressWarnings({"NullableProblems"})
@NotNull
DeclarationDescriptor getContainingDeclaration();
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/annotations/AnnotationArgumentVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/annotations/AnnotationArgumentVisitor.java
index 06229b57f33..ef2fe79ae12 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/annotations/AnnotationArgumentVisitor.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/annotations/AnnotationArgumentVisitor.java
@@ -48,4 +48,6 @@ public interface AnnotationArgumentVisitor {
R visitArrayValue(ArrayValue value, D data);
R visitAnnotationValue(AnnotationValue value, D data);
+
+ R visitJavaClassValue(JavaClassValue value, D data);
}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/ClassDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/ClassDescriptorImpl.java
index 765970371c3..4c186db167b 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/ClassDescriptorImpl.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/ClassDescriptorImpl.java
@@ -141,11 +141,6 @@ public class ClassDescriptorImpl extends DeclarationDescriptorNonRootImpl implem
return kind;
}
- @Override
- public boolean isClassObjectAValue() {
- return true;
- }
-
@Override
public R accept(DeclarationDescriptorVisitor visitor, D data) {
return visitor.visitClassDescriptor(this, data);
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/ConstructorDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/ConstructorDescriptorImpl.java
index abe1d6f6d50..e0560aea197 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/ConstructorDescriptorImpl.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/ConstructorDescriptorImpl.java
@@ -22,6 +22,7 @@ import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.name.Name;
+import org.jetbrains.jet.lang.types.JetType;
import java.util.Collections;
import java.util.List;
@@ -36,7 +37,11 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements
private static final Name NAME = Name.special("");
public ConstructorDescriptorImpl(@NotNull ClassDescriptor containingDeclaration, @NotNull List annotations, boolean isPrimary) {
- super(containingDeclaration, annotations, NAME, Kind.DECLARATION);
+ this(containingDeclaration, annotations, isPrimary, Kind.DECLARATION);
+ }
+
+ public ConstructorDescriptorImpl(@NotNull ClassDescriptor containingDeclaration, @NotNull List annotations, boolean isPrimary, Kind kind) {
+ super(containingDeclaration, annotations, NAME, kind);
this.isPrimary = isPrimary;
}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/FunctionDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/FunctionDescriptorImpl.java
index 83a6f74db61..3b8846e3eb0 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/FunctionDescriptorImpl.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/FunctionDescriptorImpl.java
@@ -51,7 +51,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
@NotNull DeclarationDescriptor containingDeclaration,
@NotNull List annotations,
@NotNull Name name,
- Kind kind) {
+ @NotNull Kind kind) {
super(containingDeclaration, annotations, name);
this.original = this;
this.kind = kind;
@@ -62,7 +62,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
@NotNull FunctionDescriptor original,
@NotNull List annotations,
@NotNull Name name,
- Kind kind) {
+ @NotNull Kind kind) {
super(containingDeclaration, annotations, name);
this.original = original;
this.kind = kind;
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/LazySubstitutingClassDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/LazySubstitutingClassDescriptor.java
index 357575ff9cd..901b8b21c58 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/LazySubstitutingClassDescriptor.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/LazySubstitutingClassDescriptor.java
@@ -180,11 +180,6 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
return original.isInner();
}
- @Override
- public boolean isClassObjectAValue() {
- return original.isClassObjectAValue();
- }
-
@Override
public R accept(DeclarationDescriptorVisitor visitor, D data) {
return visitor.visitClassDescriptor(this, data);
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/MutableClassDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/MutableClassDescriptor.java
index 65cf9c13207..1a4c0997569 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/MutableClassDescriptor.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/MutableClassDescriptor.java
@@ -26,7 +26,6 @@ import org.jetbrains.jet.lang.resolve.BindingTrace;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.*;
-import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -224,7 +223,7 @@ public class MutableClassDescriptor extends MutableClassDescriptorLite {
}
@Override
- public ClassObjectStatus setClassObjectDescriptor(@NotNull final MutableClassDescriptorLite classObjectDescriptor) {
+ public ClassObjectStatus setClassObjectDescriptor(@NotNull MutableClassDescriptorLite classObjectDescriptor) {
ClassObjectStatus r = superBuilder.setClassObjectDescriptor(classObjectDescriptor);
if (r != ClassObjectStatus.OK) {
return r;
@@ -232,19 +231,7 @@ public class MutableClassDescriptor extends MutableClassDescriptorLite {
// Members of the class object are accessible from the class
// The scope must be lazy, because classObjectDescriptor may not by fully built yet
- scopeForMemberResolution.importScope(new AbstractScopeAdapter() {
- @NotNull
- @Override
- protected JetScope getWorkerScope() {
- return classObjectDescriptor.getDefaultType().getMemberScope();
- }
-
- @NotNull
- @Override
- public List getImplicitReceiversHierarchy() {
- return Collections.singletonList(classObjectDescriptor.getThisAsReceiverParameter());
- }
- });
+ scopeForMemberResolution.importScope(new ClassObjectMixinScope(classObjectDescriptor));
return ClassObjectStatus.OK;
}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/MutableClassDescriptorLite.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/MutableClassDescriptorLite.java
index cdbcddd9a8e..260fbd71bcd 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/MutableClassDescriptorLite.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/MutableClassDescriptorLite.java
@@ -133,12 +133,6 @@ public abstract class MutableClassDescriptorLite extends ClassDescriptorBase {
return classObjectType;
}
- @Override
- public boolean isClassObjectAValue() {
- return true;
- }
-
-
@NotNull
@Override
public ClassKind getKind() {
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/SimpleFunctionDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/SimpleFunctionDescriptorImpl.java
index cbd83b0b807..e04e6618a52 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/SimpleFunctionDescriptorImpl.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/SimpleFunctionDescriptorImpl.java
@@ -34,7 +34,7 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
@NotNull DeclarationDescriptor containingDeclaration,
@NotNull List annotations,
@NotNull Name name,
- Kind kind) {
+ @NotNull Kind kind) {
super(containingDeclaration, annotations, name, kind);
}
@@ -43,7 +43,7 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme
@NotNull SimpleFunctionDescriptor original,
@NotNull List annotations,
@NotNull Name name,
- Kind kind) {
+ @NotNull Kind kind) {
super(containingDeclaration, original, annotations, name, kind);
}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/TypeParameterDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/TypeParameterDescriptorImpl.java
index 513e5753afd..36dc836625b 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/TypeParameterDescriptorImpl.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/TypeParameterDescriptorImpl.java
@@ -245,11 +245,6 @@ public class TypeParameterDescriptorImpl extends DeclarationDescriptorNonRootImp
return classObjectBoundsAsType;
}
- @Override
- public boolean isClassObjectAValue() {
- return true;
- }
-
public void addClassObjectBound(@NotNull JetType bound) {
checkUninitialized();
classObjectUpperBounds.add(bound); // TODO : Duplicates?
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java
index aad818c3785..ed4de016321 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java
@@ -114,6 +114,7 @@ public interface Errors {
DiagnosticFactory1 NOT_AN_ANNOTATION_CLASS = DiagnosticFactory1.create(ERROR);
DiagnosticFactory0 ANNOTATION_CLASS_WITH_BODY = DiagnosticFactory0.create(ERROR);
+ DiagnosticFactory0 INVALID_TYPE_OF_ANNOTATION_MEMBER = DiagnosticFactory0.create(ERROR);
// Classes and traits
@@ -337,6 +338,7 @@ public interface Errors {
DiagnosticFactory1>> OVERLOAD_RESOLUTION_AMBIGUITY = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1>> NONE_APPLICABLE = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1>> CANNOT_COMPLETE_RESOLVE = DiagnosticFactory1.create(ERROR);
+ DiagnosticFactory1>> UNRESOLVED_REFERENCE_WRONG_RECEIVER = DiagnosticFactory1.create(ERROR);
DiagnosticFactory0 DANGLING_FUNCTION_LITERAL_ARGUMENT_SUSPECTED = DiagnosticFactory0.create(WARNING);
@@ -358,7 +360,7 @@ public interface Errors {
// Multi-declarations
DiagnosticFactory0 INITIALIZER_REQUIRED_FOR_MULTIDECLARATION = DiagnosticFactory0.create(ERROR, DEFAULT);
- DiagnosticFactory1 COMPONENT_FUNCTION_MISSING = DiagnosticFactory1.create(ERROR, DEFAULT);
+ DiagnosticFactory2 COMPONENT_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR, DEFAULT);
DiagnosticFactory2>> COMPONENT_FUNCTION_AMBIGUITY = DiagnosticFactory2.create(ERROR, DEFAULT);
DiagnosticFactory3 COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR, DEFAULT);
@@ -548,7 +550,7 @@ public interface Errors {
// Error sets
ImmutableSet extends AbstractDiagnosticFactory> UNRESOLVED_REFERENCE_DIAGNOSTICS = ImmutableSet.of(
- UNRESOLVED_REFERENCE, NAMED_PARAMETER_NOT_FOUND);
+ UNRESOLVED_REFERENCE, NAMED_PARAMETER_NOT_FOUND, UNRESOLVED_REFERENCE_WRONG_RECEIVER);
ImmutableSet extends AbstractDiagnosticFactory> UNUSED_ELEMENT_DIAGNOSTICS = ImmutableSet.of(
UNUSED_VARIABLE, UNUSED_PARAMETER, ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE);
ImmutableSet extends AbstractDiagnosticFactory> REDECLARATION_DIAGNOSTICS = ImmutableSet.of(
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/DefaultErrorMessages.java
index 409d7dfdf1b..b578856dff6 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/DefaultErrorMessages.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/rendering/DefaultErrorMessages.java
@@ -113,7 +113,7 @@ public class DefaultErrorMessages {
MAP.put(VARIABLE_WITH_NO_TYPE_NO_INITIALIZER, "This variable must either have a type annotation or be initialized");
MAP.put(INITIALIZER_REQUIRED_FOR_MULTIDECLARATION, "Initializer required for multi-declaration");
- MAP.put(COMPONENT_FUNCTION_MISSING, "Multi-declaration initializer must have a ''{0}()'' function", TO_STRING);
+ MAP.put(COMPONENT_FUNCTION_MISSING, "Multi-declaration initializer of type {1} must have a ''{0}()'' function", TO_STRING, RENDER_TYPE);
MAP.put(COMPONENT_FUNCTION_AMBIGUITY, "Function ''{0}()'' is ambiguous for this expression: {1}", TO_STRING, AMBIGUOUS_CALLS);
MAP.put(COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH, "''{0}()'' function returns ''{1}'', but ''{2}'' is expected",
TO_STRING, RENDER_TYPE, RENDER_TYPE);
@@ -410,6 +410,7 @@ public class DefaultErrorMessages {
MAP.put(OVERLOAD_RESOLUTION_AMBIGUITY, "Overload resolution ambiguity: {0}", AMBIGUOUS_CALLS);
MAP.put(NONE_APPLICABLE, "None of the following functions can be called with the arguments supplied: {0}", AMBIGUOUS_CALLS);
MAP.put(CANNOT_COMPLETE_RESOLVE, "Cannot choose among the following candidates without completing type inference: {0}", AMBIGUOUS_CALLS);
+ MAP.put(UNRESOLVED_REFERENCE_WRONG_RECEIVER, "Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: {0}", AMBIGUOUS_CALLS);
MAP.put(NO_VALUE_FOR_PARAMETER, "No value passed for parameter {0}", NAME);
MAP.put(MISSING_RECEIVER, "A receiver of type {0} is required", RENDER_TYPE);
@@ -433,6 +434,7 @@ public class DefaultErrorMessages {
MAP.put(NOT_AN_ANNOTATION_CLASS, "''{0}'' is not an annotation class", TO_STRING);
MAP.put(ANNOTATION_CLASS_WITH_BODY, "Body is not allowed for annotation class");
+ MAP.put(INVALID_TYPE_OF_ANNOTATION_MEMBER, "Invalid type of annotation member");
MAP.put(DEFAULT_VALUE_NOT_ALLOWED_IN_OVERRIDE, "An overriding function is not allowed to specify default values for its parameters");
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.java
index 22a15e9a39f..b4aa38c5925 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.java
@@ -453,4 +453,14 @@ public class JetPsiFactory {
return (JetWhenExpression) createExpression(project, sb.toString());
}
}
+
+ public static JetExpression createFunctionBody(Project project, @NotNull String bodyText) {
+ JetFunction func = createFunction(project, "fun foo() {\n" + bodyText + "\n}");
+ return func.getBodyExpression();
+ }
+
+ public static JetClassObject createEmptyClassObject(Project project) {
+ JetClass klass = createClass(project, "class foo { class object { } }");
+ return klass.getClassObject();
+ }
}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java
index 7f1f7e3093e..a5505b3783a 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java
@@ -553,6 +553,10 @@ public class JetPsiUtil {
return getOutermostClassOrObject(classOrObject) == null;
}
+ public static boolean isTrait(@NotNull JetClassOrObject classOrObject) {
+ return classOrObject instanceof JetClass && ((JetClass) classOrObject).isTrait();
+ }
+
@Nullable
public static JetClassOrObject getOutermostClassOrObject(@NotNull JetClassOrObject classOrObject) {
JetClassOrObject current = classOrObject;
@@ -653,8 +657,9 @@ public class JetPsiUtil {
JetTokens.ALL_ASSIGNMENTS.contains(((JetBinaryExpression) element).getOperationToken());
}
- public static boolean isBranchedExpression(@Nullable PsiElement element) {
- return element instanceof JetIfExpression || element instanceof JetWhenExpression;
+ public static boolean isOrdinaryAssignment(@NotNull PsiElement element) {
+ return element instanceof JetBinaryExpression &&
+ ((JetBinaryExpression) element).getOperationToken().equals(JetTokens.EQ);
}
@Nullable
@@ -705,17 +710,6 @@ public class JetPsiUtil {
return false;
}
- @NotNull
- public static > C getBlockVariableDeclarations(@NotNull JetBlockExpression block, @NotNull C collection) {
- for (JetElement element : block.getStatements()) {
- if (element instanceof JetVariableDeclaration) {
- collection.add((JetVariableDeclaration) element);
- }
- }
-
- return collection;
- }
-
public static boolean checkWhenExpressionHasSingleElse(@NotNull JetWhenExpression whenExpression) {
int elseCount = 0;
for (JetWhenEntry entry : whenExpression.getEntries()) {
@@ -743,6 +737,11 @@ public class JetPsiUtil {
return element != null ? element.getText() : "";
}
+ @Nullable
+ public static String getNullableText(@Nullable PsiElement element) {
+ return element != null ? element.getText() : null;
+ }
+
/**
* CommentUtilCore.isComment fails if element inside comment.
*
@@ -780,22 +779,22 @@ public class JetPsiUtil {
}
@Nullable
- public static T getOutermostJetElement(
+ public static JetElement getOutermostDescendantElement(
@Nullable PsiElement root,
boolean first,
- @NotNull final Class extends T>... elementTypes
+ final @NotNull Predicate predicate
) {
if (!(root instanceof JetElement)) return null;
- final List results = Lists.newArrayList();
+ final List results = Lists.newArrayList();
((JetElement) root).accept(
new JetVisitorVoid() {
@Override
public void visitJetElement(JetElement element) {
- if (PsiTreeUtil.instanceOf(element, elementTypes)) {
+ if (predicate.apply(element)) {
//noinspection unchecked
- results.add((T) element);
+ results.add(element);
}
else {
element.acceptChildren(this);
@@ -835,4 +834,24 @@ public class JetPsiUtil {
}
return null;
}
+
+ @Nullable
+ public static PsiElement skipSiblingsBackwardByPredicate(@Nullable PsiElement element, Predicate elementsToSkip) {
+ if (element == null) return null;
+ for (PsiElement e = element.getPrevSibling(); e != null; e = e.getPrevSibling()) {
+ if (elementsToSkip.apply(e)) continue;
+ return e;
+ }
+ return null;
+ }
+
+ @Nullable
+ public static PsiElement skipSiblingsForwardByPredicate(@Nullable PsiElement element, Predicate elementsToSkip) {
+ if (element == null) return null;
+ for (PsiElement e = element.getNextSibling(); e != null; e = e.getNextSibling()) {
+ if (elementsToSkip.apply(e)) continue;
+ return e;
+ }
+ return null;
+ }
}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java
index 7a6f3bbf5a9..62a759df815 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java
@@ -20,26 +20,30 @@ import com.google.common.collect.Lists;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
+import org.jetbrains.jet.lang.descriptors.annotations.Annotated;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.diagnostics.Errors;
import org.jetbrains.jet.lang.psi.*;
+import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
import org.jetbrains.jet.lang.resolve.calls.util.CallMaker;
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedValueArgument;
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
-import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
+import org.jetbrains.jet.lang.resolve.constants.*;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.jet.lang.types.ErrorUtils;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices;
+import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import javax.inject.Inject;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import static org.jetbrains.jet.lang.resolve.BindingContext.ANNOTATION_DESCRIPTOR_TO_PSI_ELEMENT;
import static org.jetbrains.jet.lang.types.TypeUtils.NO_EXPECTED_TYPE;
public class AnnotationResolver {
@@ -58,34 +62,56 @@ public class AnnotationResolver {
}
@NotNull
- public List resolveAnnotations(@NotNull JetScope scope, @Nullable JetModifierList modifierList, BindingTrace trace) {
- if (modifierList == null) {
- return Collections.emptyList();
- }
- return resolveAnnotations(scope, modifierList.getAnnotationEntries(), trace);
+ public List resolveAnnotations(
+ @NotNull JetScope scope,
+ @Nullable JetModifierList modifierList,
+ @NotNull BindingTrace trace)
+ {
+ return resolveAnnotations(scope, modifierList, trace, false);
}
@NotNull
- public List resolveAnnotations(@NotNull JetScope scope, @NotNull List annotationEntryElements, BindingTrace trace) {
+ public List resolveAnnotationsWithArguments(
+ @NotNull JetScope scope,
+ @Nullable JetModifierList modifierList,
+ @NotNull BindingTrace trace
+ ) {
+ return resolveAnnotations(scope, modifierList, trace, true);
+ }
+
+ private List resolveAnnotations(
+ @NotNull JetScope scope,
+ @Nullable JetModifierList modifierList,
+ @NotNull BindingTrace trace,
+ boolean shouldResolveArguments
+ ) {
+ if (modifierList == null) {
+ return Collections.emptyList();
+ }
+ List annotationEntryElements = modifierList.getAnnotationEntries();
+
if (annotationEntryElements.isEmpty()) return Collections.emptyList();
List result = Lists.newArrayList();
for (JetAnnotationEntry entryElement : annotationEntryElements) {
AnnotationDescriptor descriptor = new AnnotationDescriptor();
resolveAnnotationStub(scope, entryElement, descriptor, trace);
trace.record(BindingContext.ANNOTATION, entryElement, descriptor);
+ if (shouldResolveArguments) {
+ resolveAnnotationArguments(entryElement, scope, trace);
+ }
result.add(descriptor);
}
return result;
}
- public void resolveAnnotationStub(@NotNull JetScope scope, @NotNull JetAnnotationEntry entryElement,
- @NotNull AnnotationDescriptor annotationDescriptor, BindingTrace trace) {
- OverloadResolutionResults results = callResolver.resolveFunctionCall(
- trace,
- scope,
- CallMaker.makeCall(ReceiverValue.NO_RECEIVER, null, entryElement),
- NO_EXPECTED_TYPE,
- DataFlowInfo.EMPTY);
+ public void resolveAnnotationStub(
+ @NotNull JetScope scope,
+ @NotNull JetAnnotationEntry entryElement,
+ @NotNull AnnotationDescriptor annotationDescriptor,
+ @NotNull BindingTrace trace
+ ) {
+ TemporaryBindingTrace temporaryBindingTrace = new TemporaryBindingTrace(trace, "Trace for resolve annotation type");
+ OverloadResolutionResults results = resolveAnnotationCall(entryElement, scope, temporaryBindingTrace);
if (results.isSuccess()) {
FunctionDescriptor descriptor = results.getResultingDescriptor();
if (!ErrorUtils.isError(descriptor)) {
@@ -102,35 +128,102 @@ public class AnnotationResolver {
}
JetType annotationType = results.getResultingDescriptor().getReturnType();
annotationDescriptor.setAnnotationType(annotationType);
- resolveArguments(results, annotationDescriptor, trace);
}
else {
annotationDescriptor.setAnnotationType(ErrorUtils.createErrorType("Unresolved annotation type"));
}
}
- private void resolveArguments(@NotNull OverloadResolutionResults results,
- @NotNull AnnotationDescriptor descriptor, BindingTrace trace) {
+ private OverloadResolutionResults resolveAnnotationCall(
+ JetAnnotationEntry annotationEntry,
+ JetScope scope,
+ BindingTrace trace
+ ) {
+ return callResolver.resolveFunctionCall(
+ trace, scope,
+ CallMaker.makeCall(ReceiverValue.NO_RECEIVER, null, annotationEntry),
+ NO_EXPECTED_TYPE,
+ DataFlowInfo.EMPTY);
+ }
+
+ public void resolveAnnotationsArguments(@NotNull JetScope scope, @Nullable JetModifierList modifierList, @NotNull BindingTrace trace) {
+ if (modifierList == null) {
+ return;
+ }
+
+ for (JetAnnotationEntry annotationEntry : modifierList.getAnnotationEntries()) {
+ resolveAnnotationArguments(annotationEntry, scope, trace);
+ }
+ }
+
+ public void resolveAnnotationsArguments(@NotNull Annotated descriptor, @NotNull BindingTrace trace, @NotNull JetScope scope) {
+ for (AnnotationDescriptor annotationDescriptor : descriptor.getAnnotations()) {
+ JetAnnotationEntry annotationEntry = trace.getBindingContext().get(ANNOTATION_DESCRIPTOR_TO_PSI_ELEMENT, annotationDescriptor);
+ assert annotationEntry != null : "Cannot find annotation entry: " + annotationDescriptor;
+ resolveAnnotationArguments(annotationEntry, scope, trace);
+ }
+ }
+
+ private void resolveAnnotationArguments(
+ @NotNull JetAnnotationEntry annotationEntry,
+ @NotNull JetScope scope,
+ @NotNull BindingTrace trace
+ ) {
+ OverloadResolutionResults results = resolveAnnotationCall(annotationEntry, scope, trace);
+ if (results.isSuccess()) {
+ AnnotationDescriptor annotationDescriptor = trace.getBindingContext().get(BindingContext.ANNOTATION, annotationEntry);
+ assert annotationDescriptor != null : "Annotation descriptor should be created before resolving arguments for " + annotationEntry.getText();
+ resolveAnnotationArgument(annotationDescriptor, results.getResultingCall(), trace);
+ }
+ }
+
+ private void resolveAnnotationArgument(
+ @NotNull AnnotationDescriptor annotationDescriptor,
+ @NotNull ResolvedCall extends CallableDescriptor> call,
+ @NotNull BindingTrace trace
+ ) {
for (Map.Entry descriptorToArgument :
- results.getResultingCall().getValueArguments().entrySet()) {
- // TODO: are varargs supported here?
- List valueArguments = descriptorToArgument.getValue().getArguments();
+ call.getValueArguments().entrySet()) {
ValueParameterDescriptor parameterDescriptor = descriptorToArgument.getKey();
- for (ValueArgument argument : valueArguments) {
- JetExpression argumentExpression = argument.getArgumentExpression();
- if (argumentExpression != null) {
- CompileTimeConstant> compileTimeConstant =
- resolveAnnotationArgument(argumentExpression, parameterDescriptor.getType(), trace);
- if (compileTimeConstant != null) {
- descriptor.setValueArgument(parameterDescriptor, compileTimeConstant);
- }
+
+ JetType varargElementType = parameterDescriptor.getVarargElementType();
+ List> constants = resolveValueArguments(descriptorToArgument.getValue(), parameterDescriptor.getType(), trace);
+ if (varargElementType == null) {
+ for (CompileTimeConstant> constant : constants) {
+ annotationDescriptor.setValueArgument(parameterDescriptor, constant);
}
}
+ else {
+ JetType arrayType = KotlinBuiltIns.getInstance().getPrimitiveArrayJetTypeByPrimitiveJetType(varargElementType);
+ if (arrayType == null) {
+ arrayType = KotlinBuiltIns.getInstance().getArrayType(varargElementType);
+ }
+ annotationDescriptor.setValueArgument(parameterDescriptor, new ArrayValue(constants, arrayType));
+ }
}
}
+ @NotNull
+ private List> resolveValueArguments(
+ @NotNull ResolvedValueArgument resolvedValueArgument,
+ @NotNull JetType expectedType,
+ @NotNull BindingTrace trace
+ ) {
+ List> constants = Lists.newArrayList();
+ for (ValueArgument argument : resolvedValueArgument.getArguments()) {
+ JetExpression argumentExpression = argument.getArgumentExpression();
+ if (argumentExpression != null) {
+ CompileTimeConstant> constant = resolveAnnotationArgument(argumentExpression, expectedType, trace);
+ if (constant != null) {
+ constants.add(constant);
+ }
+ }
+ }
+ return constants;
+ }
+
@Nullable
- public CompileTimeConstant> resolveAnnotationArgument(@NotNull JetExpression expression, @NotNull final JetType expectedType, final BindingTrace trace) {
+ private CompileTimeConstant> resolveAnnotationArgument(@NotNull JetExpression expression, @NotNull final JetType expectedType, final BindingTrace trace) {
JetVisitor, Void> visitor = new JetVisitor, Void>() {
@Override
public CompileTimeConstant> visitConstantExpression(JetConstantExpression expression, Void nothing) {
@@ -166,6 +259,64 @@ public class AnnotationResolver {
return trace.get(BindingContext.COMPILE_TIME_VALUE, expression);
}
+ @Override
+ public CompileTimeConstant> visitSimpleNameExpression(JetSimpleNameExpression expression, Void data) {
+ ResolvedCall extends CallableDescriptor> resolvedCall =
+ trace.getBindingContext().get(BindingContext.RESOLVED_CALL, expression);
+ if (resolvedCall != null) {
+ CallableDescriptor callableDescriptor = resolvedCall.getResultingDescriptor();
+ if (callableDescriptor instanceof PropertyDescriptor) {
+ PropertyDescriptor propertyDescriptor = (PropertyDescriptor) callableDescriptor;
+ if (isEnumProperty(propertyDescriptor)) {
+ return new EnumValue(propertyDescriptor);
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public CompileTimeConstant> visitQualifiedExpression(JetQualifiedExpression expression, Void data) {
+ JetExpression selectorExpression = expression.getSelectorExpression();
+ if (selectorExpression != null) {
+ return selectorExpression.accept(this, null);
+ }
+ return super.visitQualifiedExpression(expression, data);
+ }
+
+ @Override
+ public CompileTimeConstant> visitCallExpression(JetCallExpression expression, Void data) {
+ ResolvedCall extends CallableDescriptor> call =
+ trace.getBindingContext().get(BindingContext.RESOLVED_CALL, (expression).getCalleeExpression());
+ if (call != null) {
+ CallableDescriptor resultingDescriptor = call.getResultingDescriptor();
+ if (AnnotationUtils.isArrayMethodCall(call)) {
+ JetType type = resultingDescriptor.getValueParameters().iterator().next().getVarargElementType();
+ List> arguments = Lists.newArrayList();
+ for (ResolvedValueArgument descriptorToArgument : call.getValueArguments().values()) {
+ arguments.addAll(resolveValueArguments(descriptorToArgument, type, trace));
+ }
+ return new ArrayValue(arguments, resultingDescriptor.getReturnType());
+ }
+
+ if (resultingDescriptor instanceof ConstructorDescriptor) {
+ JetType constructorReturnType = resultingDescriptor.getReturnType();
+ assert constructorReturnType != null : "Constructor should have return type";
+ if (DescriptorUtils.isAnnotationClass(constructorReturnType.getConstructor().getDeclarationDescriptor())) {
+ AnnotationDescriptor descriptor = new AnnotationDescriptor();
+ descriptor.setAnnotationType(constructorReturnType);
+ resolveAnnotationArgument(descriptor, call, trace);
+ return new AnnotationValue(descriptor);
+ }
+ }
+
+ if (AnnotationUtils.isJavaClassMethodCall(call)) {
+ return new JavaClassValue(resultingDescriptor.getReturnType());
+ }
+ }
+ return null;
+ }
+
@Override
public CompileTimeConstant> visitJetElement(JetElement element, Void nothing) {
// TODO:
@@ -176,6 +327,16 @@ public class AnnotationResolver {
return expression.accept(visitor, null);
}
+ private static boolean isEnumProperty(@NotNull PropertyDescriptor descriptor) {
+ if (DescriptorUtils.isKindOf(descriptor.getType(), ClassKind.ENUM_CLASS)) {
+ DeclarationDescriptor enumClassObject = descriptor.getContainingDeclaration();
+ if (DescriptorUtils.isKindOf(enumClassObject, ClassKind.CLASS_OBJECT)) {
+ return DescriptorUtils.isKindOf(enumClassObject.getContainingDeclaration(), ClassKind.ENUM_CLASS);
+ }
+ }
+ return false;
+ }
+
@NotNull
public List getResolvedAnnotations(@Nullable JetModifierList modifierList, BindingTrace trace) {
if (modifierList == null) {
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationUtils.java
new file mode 100644
index 00000000000..947f0a498f2
--- /dev/null
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationUtils.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.lang.resolve;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
+import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
+import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
+import org.jetbrains.jet.lang.psi.JetParameter;
+import org.jetbrains.jet.lang.psi.JetTypeReference;
+import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
+import org.jetbrains.jet.lang.types.JetType;
+import org.jetbrains.jet.lang.types.TypeProjection;
+import org.jetbrains.jet.lang.types.TypeUtils;
+import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
+
+import java.util.List;
+
+import static org.jetbrains.jet.lang.diagnostics.Errors.INVALID_TYPE_OF_ANNOTATION_MEMBER;
+import static org.jetbrains.jet.lang.resolve.BindingContext.VALUE_PARAMETER;
+import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isAnnotationClass;
+import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isEnumClass;
+
+public class AnnotationUtils {
+
+ public static void checkConstructorParametersType(@NotNull List parameters, @NotNull BindingTrace trace) {
+ for (JetParameter parameter : parameters) {
+ VariableDescriptor parameterDescriptor = trace.getBindingContext().get(VALUE_PARAMETER, parameter);
+ if (parameterDescriptor == null) continue;
+ JetType parameterType = parameterDescriptor.getType();
+ if (!isAcceptableTypeForAnnotationParameter(parameterType)) {
+ JetTypeReference typeReference = parameter.getTypeReference();
+ if (typeReference != null) {
+ trace.report(INVALID_TYPE_OF_ANNOTATION_MEMBER.on(typeReference));
+ }
+ }
+ }
+ }
+
+ private static boolean isAcceptableTypeForAnnotationParameter(@NotNull JetType parameterType) {
+ if (parameterType.isNullable()) {
+ return false;
+ }
+ ClassDescriptor typeDescriptor = TypeUtils.getClassDescriptor(parameterType);
+ if (typeDescriptor == null) {
+ return false;
+ }
+
+ KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
+ if (isEnumClass(typeDescriptor) ||
+ isAnnotationClass(typeDescriptor) ||
+ isJavaLangClass(typeDescriptor) ||
+ builtIns.isPrimitiveArray(parameterType) ||
+ builtIns.isPrimitiveType(parameterType) ||
+ builtIns.getStringType().equals(parameterType)) {
+ return true;
+ }
+
+ if (builtIns.isArray(parameterType)) {
+ List arguments = parameterType.getArguments();
+ if (arguments.size() == 1) {
+ JetType arrayType = arguments.get(0).getType();
+ if (arrayType.isNullable()) {
+ return false;
+ }
+ ClassDescriptor arrayTypeDescriptor = TypeUtils.getClassDescriptor(arrayType);
+ if (arrayTypeDescriptor != null) {
+ return isEnumClass(arrayTypeDescriptor) ||
+ isAnnotationClass(arrayTypeDescriptor) ||
+ isJavaLangClass(arrayTypeDescriptor) ||
+ builtIns.getStringType().equals(arrayType);
+ }
+ }
+ }
+ return false;
+ }
+
+ public static boolean isArrayMethodCall(@NotNull ResolvedCall resolvedCall) {
+ List annotations = resolvedCall.getResultingDescriptor().getOriginal().getAnnotations();
+ if (annotations != null) {
+ for (AnnotationDescriptor annotation : annotations) {
+ //noinspection ConstantConditions
+ if ("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().asString())) {
+ return "kotlin.arrays.array".equals(annotation.getAllValueArguments().values().iterator().next().getValue());
+ }
+ }
+ }
+ return false;
+ }
+
+ public static boolean isJavaClassMethodCall(@NotNull ResolvedCall resolvedCall) {
+ List annotations = resolvedCall.getResultingDescriptor().getOriginal().getAnnotations();
+ if (annotations != null) {
+ for (AnnotationDescriptor annotation : annotations) {
+ //noinspection ConstantConditions
+ if ("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().asString())) {
+ return "kotlin.javaClass.function".equals(annotation.getAllValueArguments().values().iterator().next().getValue());
+ }
+ }
+ }
+ return false;
+ }
+
+ private static boolean isJavaLangClass(ClassDescriptor descriptor) {
+ return "java.lang.Class".equals(DescriptorUtils.getFQName(descriptor).asString());
+ }
+
+ private AnnotationUtils() {
+ }
+}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java
index 9e51ebd58c2..1fce91e3081 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContext.java
@@ -76,6 +76,7 @@ public interface BindingContext {
WritableSlice> COMPILE_TIME_VALUE = Slices.createSimpleSlice();
WritableSlice TYPE = Slices.createSimpleSlice();
WritableSlice EXPRESSION_TYPE = new BasicWritableSlice