From d9edc5f22114eb7020f64e0a4914e08f723bac12 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Fri, 22 Dec 2017 21:48:08 +0300 Subject: [PATCH] Replace Regex constructor-like functions with secondary constructors Historically secondary constructors were not supported in Kotlin/JS, so they had to be emulated with constructor-like top level functions, now they can be rewritten as true secondary constructors. #KT-22003 Fixed --- js/js.libraries/src/core/regex.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/js/js.libraries/src/core/regex.kt b/js/js.libraries/src/core/regex.kt index 95c14567019..f61adcec6cc 100644 --- a/js/js.libraries/src/core/regex.kt +++ b/js/js.libraries/src/core/regex.kt @@ -45,6 +45,13 @@ public data class MatchGroup(val value: String) */ public class Regex(pattern: String, options: Set) { + /** Creates a regular expression from the specified [pattern] string and the specified single [option]. */ + public constructor(pattern: String, option: RegexOption) : this(pattern, setOf(option)) + + /** Creates a regular expression from the specified [pattern] string and the default options. */ + public constructor(pattern: String) : this(pattern, emptySet()) + + /** The pattern string of this regular expression. */ public val pattern: String = pattern /** The set of options that were used to create this regular expression. */ @@ -170,10 +177,14 @@ public class Regex(pattern: String, options: Set) { } /** Creates a regular expression from the specified [pattern] string and the specified single [option]. */ -public fun Regex(pattern: String, option: RegexOption): Regex = Regex(pattern, setOf(option)) +@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) +@JsName("Regex_sb3q2\$") +public fun Regex_0(pattern: String, option: RegexOption): Regex = Regex(pattern, setOf(option)) /** Creates a regular expression from the specified [pattern] string and the default options. */ -public fun Regex(pattern: String): Regex = Regex(pattern, emptySet()) +@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) +@JsName("Regex_61zpoe\$") +public fun Regex_1(pattern: String): Regex = Regex(pattern, emptySet())